TCP/IP Socket Connection VxWorks - Windows problem - VxWorks

This is a discussion on TCP/IP Socket Connection VxWorks - Windows problem - VxWorks ; Hi, I have one application in VxWorks that works as a client. It connects to a server on a Windows XP computer, and sends data to it over tcp/ip socket. When I start the Windows application first, the VxWorks application ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: TCP/IP Socket Connection VxWorks - Windows problem

  1. TCP/IP Socket Connection VxWorks - Windows problem

    Hi,

    I have one application in VxWorks that works as a client. It connects to a
    server on a Windows XP computer, and sends data to it over tcp/ip socket.

    When I start the Windows application first, the VxWorks application connects
    to the server (on the XP) and everything works well. I send gigabytes with
    no hitch.

    But if I start my VxWorks application first, I never manage to connect..

    The routine in VxWorks works something like this:

    sFd = socket (AF_INET, SOCK_STREAM, 0)
    while (!connected)
    {
    if (connectWithTimeout(sFd, (struct sockaddr *) &serverAddr,
    sockAddrSize, &connect_timeout) == ERROR)
    printf("Error - retrying...\n");
    else
    connected=TRUE;
    }

    I have set the connect_timeout to 5 seconds, and the above loop loops
    through forever, printing "Error - retying..." every 5 secs.

    Does anyone know a better way of doing what I want?

    Thanks,
    jostein



  2. Re: TCP/IP Socket Connection VxWorks - Windows problem

    Hi justein,
    I think the explantion is simple.

    SERVER SHOULD ALWAYS RUN FIRST.
    Thats why ur getting the error.

    Make Vxworks as server , then u can start the vxworks first and see.

    All the best.
    vijay


  3. Re: TCP/IP Socket Connection VxWorks - Windows problem

    Thanks vijay,
    but the problem is that this is a dual system configuration where I don't
    necessarily know which system is running first.

    I need the server on the Windows XP machine, as this is also functioning as
    server for several other computers. So I need some way of figuring out how
    to connect the VxWorks to the server even though the first few attempts may
    happen while the server is not ready yet...

    Thanks!
    -jostein



  4. Re: TCP/IP Socket Connection VxWorks - Windows problem

    Hi,
    in case anyone is interested, here is the solution:

    If no success in connect, close the socket. Then reopen socket and try
    connect again.

    I simply moved the sFd=socket() call into the while loop, and made sure I
    closed the socket if no connect. Now it works well.

    -jostein



    "Jostein Trones" wrote in message
    news:nIKdnU6E_8l5v8je4p2dnA@telenor.com...
    > Hi,
    >
    > I have one application in VxWorks that works as a client. It connects to a
    > server on a Windows XP computer, and sends data to it over tcp/ip socket.
    >
    > When I start the Windows application first, the VxWorks application
    > connects to the server (on the XP) and everything works well. I send
    > gigabytes with no hitch.
    >
    > But if I start my VxWorks application first, I never manage to connect..
    >
    > The routine in VxWorks works something like this:
    >
    > sFd = socket (AF_INET, SOCK_STREAM, 0)
    > while (!connected)
    > {
    > if (connectWithTimeout(sFd, (struct sockaddr *) &serverAddr,
    > sockAddrSize, &connect_timeout) == ERROR)
    > printf("Error - retrying...\n");
    > else
    > connected=TRUE;
    > }
    >
    > I have set the connect_timeout to 5 seconds, and the above loop loops
    > through forever, printing "Error - retying..." every 5 secs.
    >
    > Does anyone know a better way of doing what I want?
    >
    > Thanks,
    > jostein
    >
    >




  5. Re: TCP/IP Socket Connection VxWorks - Windows problem

    Hi jostein, would you please let me know your email cause I have some question about the Socket connection between vxworks and windows for my project.

+ Reply to Thread