ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Socket Programming

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Socket Programming

    Hi gang,

    Hope you're all keeping warm this winter. It's been very cold and snowy here in Pennsylvania. Although, it sounds like it's going to warm up this week.

    My question: I am working on a project to send & receive data from a Fedex server using sockets. I am currently just getting started and just trying to get a connection to the server, but am not having any luck. Our AS400 and the Fedex server are both on the internal network, and I have been told by our network people that we are not blocking any ports. I have done a netstat -an on the Fedex server and here are the results:

    Click image for larger version

Name:	NETSTAT.jpg
Views:	1
Size:	35.6 KB
ID:	127986

    Port 2000 is the port that I am trying to communicate with. Here is a snippet of code that I am trying to use to connect to the server:



    // Convert IP address from dotted ecimal format to 32 bit address format.
    IP = inet_addr('10.10.3.60');
    Port = 2000;

    // Convert IP address from dotted ecimal format to 32 bit address format.
    Sock = socket(AF_INET:SOCK_STREAM:IPPROTO_IP);

    // Ask the operating system for some memory to store our socket address into.
    addrlen = %size(sockaddr);
    p_connto = %alloc(addrlen);

    // Point the socket address structure at the newly allocated area of memory.
    p_sockaddr = p_connto;

    // Populate the sockaddr_in structure.
    sin_family = AF_INET;
    sin_addr = IP;
    sin_port = Port;
    sin_zero = *ALLx'00';

    // Connect to socket.
    rc = connect(Sock: p_connto: addrlen);
    IF rc < 0;


    When it hits the connect, I just sits there for a minute or two, and then eventually fails with an rc of -1. I checked the TCP/IP status, and it is showing:
    Click image for larger version

Name:	TCP Status.JPG
Views:	1
Size:	40.8 KB
ID:	127987

    I have tried to TELNET to that address/port, and I couldn't get connected, although I can ping the Fedex server from our AS400.

    Does anyone have any suggestions on what might be my issue, or anything else I can try to troubleshoot the situation?

    Thanks in advance,

    John

  • #2
    Re: Socket Programming

    You didn't tell us what the error is (by checking 'errno') after the connect failed.

    But, the fact that this fails when you use TELNET makes ir rather clear that it's not your program's fault. Something is preventing it's ability to connect. Most likely, a firewall is blocking port 2000, since you say that the socket sits in 'SYN sent' state, which means it's sending the connect request and not getting any response. This usually means that a packet filtering firewall is discarding the packet, so you send the request, but it discards it and therefore there's never a response.

    Comment


    • #3
      Re: Socket Programming

      Scott, the error was 3447/ETIMEDOUT.

      Comment


      • #4
        Re: Socket Programming

        That fits perfectly... it really sounds like a firewall (or similar) is blocking your ability to connect. It could be something else, like misconfigured routing, but that seems very unlikely. I'd say 99% chance that there's some sort of firewall that's blocking things.

        Comment


        • #5
          Re: Socket Programming

          Scott, you got it right. I got our server guy to look into it, and he said that there was a firewall running on that specific server. He shut it down and had me try a transaction, and it worked. So, he reconfigured it so I can use that port and everything is working great now.

          Thank you, I really appreciate your help!

          John

          Comment


          • #6
            Re: Socket Programming

            No problem, glad it helped!

            Comment

            Working...
            X