Q
Problem solve Get help with specific problems with your technologies, process and projects.

Communicate with a Windows 2000 server via Socket connection

I'm trying to communicate with a Windows 2000 server via Socket connection. I am able to connect, but when it comes to writing a record to the Socket, the person never see it and when I read for a response the connecton hangs for a long time, but I eventually get the message that I was disconnected by the remote Socket. Here is my code:
 
C                   Eval      sd=socket(AF_INET: SOCK_STREAM: 0)    
 *                                                                  
------------ 15 data records excluded ------------------------------
C                   Eval      serveraddr=*allx'00'                  
C                   Eval      sin_family=AF_INET                    
                                                                    
C                   Move      W1ServPortx   Servport                
C                   Move      W1ServAddrx   ServerParm              
C                   Eval      sin_port=SERVPORT                     
C                   Eval      SERVERParm=%trim(SERVERParm) + x'00'  
                                                                    
C                   Eval      sin_addr = inet_addr(ServerParm)      
------------ 26 data records excluded ------------------------------
C                   Eval      rc=connect(sd:                        
C                                        %addr(serveraddr):         
C                                        %size(serveraddr))         
------------ 43 data records excluded ------------------------------
C                   Eval      rc=send(sd: %addr(SocketData)         
C                                         :SockDtaLen:0)    
------------ 11 data records excluded ----------------------
C                   Eval      rc=recv(sd: %addr(SocketData):
C                                         SockDtaLen:0)     

Any guidance is appreciated.

Your code looks OK, however, some things need to be checked.

1. What is the return code from the send API? The return code should be the length of the data you sent.

2. Did you translate the EBCDIC string to ASCII before sending? If data was sent in EBCDIC it can make problems to the windows program that will get the "strange character."

3. Did you make sure that the sockdtalen is correct? sockdtalen is the length of structure you sent.

4. It is not surprising that the receive is blocked because the remote windows program probably did not send data to you.

5. Please note that some of the problems may be the remote program "fault", try to test the remote program by using one of the socket tools available.

==================================
MORE INFORMATION ON THIS TOPIC
==================================

Visit the ITKnowledge Exchange and get answers to your connectivity questions fast.

The Best Web Links: Tips, tutorials and more.

PC/Windows connectivity expert Shahar Mor is available to answer your toughest networking questions. Ask Shahar a question or read his previously answered questions here.

Dig Deeper on Physical connections to iSeries

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close