× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




Hello all,

I am attempting to socket from a win95 pc to an as400. Both systems are on the 
same local ethernet lan. Both behind the firewall.
When I run connect( ) on the pc, a "WSAECONNREFUSED" ( the attempt to connect 
was forcefully rejected ) error code is returned.

My "Listen" pgm is running on the as400.  It was able to rcv data on a loopback 
test, so I am reasonably sure it is coded correctly.

Do I have to enable anything on the 400 or pc before socketing from one system 
to the other?  Any ideas?  Why the WSAECONNREFUSED error?

Does the 400 log socket connection attempts that are refused?

Thanks,
Steve Richter

Here is the code.  First the c code on the pc, then the rpg ile as400 code.

{
SOCKET hSock;
SOCKADDR_IN addr ;
WSADATA wsaData ;
int nRc ;
CString sError ;
WORD wWsaVer ;

wWsaVer = MAKEWORD( 2, 2 ) ;
nRc = WSAStartup( wWsaVer, &wsaData ) ;

hSock = socket (AF_INET, SOCK_STREAM, 0) ;
FillMemory( &addr, sizeof(addr), 0 ) ;
addr.sin_family = AF_INET ;
addr.sin_addr.s_addr = inet_addr( "172.xx.y.z" ) ;
addr.sin_port = 3005 ;
nRc = connect( hSock, (LPSOCKADDR)&addr, sizeof(addr) ) ;
if ( nRc != 0 )
{
sError = subsGetSocketError( ) ;
subsMessageBox( sError, "Socket Error" ) ;
}
nRc = WSACleanup( ) ;
return ;
}

** Create the socket.                                                
 C                   Eval      SD = Socket (AF_INET: SOCK_STREAM: 0 )

 ** If socket failed - End the server program with dump               
 C                   If        SD < 0
 C                   Eval      rc = SockError('ServerSocket')
 c                   Goto      EndPgm
 C                   EndIf

** Bind - set local address for the socket.
 C                   Eval      SocketAddr = *ALLX'00'
 C                   Eval      SinFamily  = AF_INET
 C                   Eval      SinPort    = 3005
 C                   Eval      SinAddr    = INADDR_ANY
 C                   Eval      rc = Bind (SD: %ADDR(SocketAddr)
 C                                          : %SIZE(SocketAddr))
 C                   If        rc < 0
 C                   Eval      rc = SockError('ServerBind')
 c                   Goto      EndPgm
 C                   EndIf

** Listen - Invite incoming connections.
 C                   Eval      rc = Listen (SD: 1)
 C                   If        rc < 0
 C                   Eval      rc = SockError('ServerListen')
 c                   Goto      EndPgm
 C                   EndIf

 ** Accept - Wait for connection request and Make connection.
 **   Accept incoming connection request from the client.
 **   A new socket (SD2) is created for the client.
 c                   Eval      SD2 = Accept( SD:
 c                                           %Addr(AccpAddr):
 c                                           %Addr(AccpAddrLgth) )
 C                   If        rc < 0
 C                   Eval      rc = SockError('ServerAccept')
 c                   Goto      EndPgm
 c                   EndIf
                
                                                                        

+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.