Help with Server / Client App

This is a discussion on Help with Server / Client App within the Networking/Device Communication forums, part of the General Programming Boards category; I'm trying to write a simple server and client app to learn WinSocks. I'm using a windows app. Server: 3 ...

  1. #1
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681

    Help with Server / Client App

    I'm trying to write a simple server and client app to learn WinSocks. I'm using a windows app.

    Server:
    3 buttons and edit box. 1 button calls WSAStartup and sets stuff up. Another starts the socket and calls listen(). 3rd stops the sockets and calls WSACleanup.

    Client.
    3 buttons and edit box. 1 button calls WSAStartup and sets stuff up. 2nd Starts socket and connect. 3rd stops the sockets and calls WSACleanup.

    Client seems to be working so far.

    Problem is with the server. I'm using a Timer to call select() to see if there is anything there. When I call select I'm getting an error of WSAEINVAL. My timeval is declared as following:

    Code:
    timeval SecTime={0,0};
    and my fd_set is as follows:

    Code:
    static fd_set ReadFDs, WriteFDs, ExceptFDs;
    and set with:
    Code:
    FD_ZERO(&ReadFDs);
    FD_ZERO(&WriteFDs);
    FD_ZERO(&ExceptFDs);
                       
    FD_SET (sock, &ReadFDs);
    FD_SET (sock, &ExceptFDs);
    select call is:
    Code:
    if ( select (0, &ReadFDs, &WriteFDs, &ExceptFDs, &SecTime) ==  SOCKET_ERROR)
    A zip file with all source code and exe is attached. anyhelp would be great. Thanks
    Attached Files Attached Files

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Ok found what was causing that error. FD_SET() has to be called right before select() for some dumb reason. I had them in seperate button actions.

    If anyone cares to look at the code and let me know of any glaring problems please feel free

  3. #3
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Actually nevermind about telling me the glaring errors, I've found a bunch of them and have changed the code a bit. Gonna have to do some cleanup work it seems.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. server client application - (i really need your help)
    By sarahnetworking in forum C Programming
    Replies: 3
    Last Post: 03-01-2008, 10:54 PM
  2. Where's the EPIPE signal?
    By marc.andrysco in forum Networking/Device Communication
    Replies: 0
    Last Post: 12-23-2006, 08:04 PM
  3. Client - Server TCP/IP MFC app..... Help!
    By amedinadiaz in forum C++ Programming
    Replies: 0
    Last Post: 10-26-2005, 12:57 PM
  4. Unicode vurses Non Unicode client server application with winsock2 query?
    By dp_76 in forum Networking/Device Communication
    Replies: 0
    Last Post: 05-16-2005, 08:26 AM
  5. storing client data in server app
    By codec in forum C++ Programming
    Replies: 4
    Last Post: 03-09-2003, 10:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21