Thread: Send/Recieve problem

  1. #16
    Registered User
    Join Date
    Jan 2003
    Posts
    99
    So, with select and the ISSET macro. This checks to see if the socket descriptor in question has activity on it and if it does then the recv function is called to get that data after it has been sent. So with this there is not an immediate threat with blocking problems, correct? or will I need to set the socket to non-blocking and when i need to recieve something loop until the number of bytes recieved is different and that would be the message?

  2. #17
    Registered User
    Join Date
    Sep 2002
    Posts
    417
    Originally posted by _Cl0wn_
    You won't need as much. You would probably only need one file to do it. You would just need to set up a menu at start up where the user can make a choice to become the server or client. If he wants to be a server then bind and listen else then he wants to be a client and then just connect to the server NOTE: the server would already need to be up to connect to. Then you could either user a while loop of send and recv or use select. I have found something that should help you with what you are doing.

    Alternating Chat
    That sounds right... only I want them to be a server and a client... but alternating is exactly what I need...

    I want it to send the 5 character string to the other server, which they can then send it back... its for a chess game, actually. Until we finish the mouse input, its based off of a character string representing coordinates: "a1:a3", which we want the other computer to receive, and then be able to send.

    Is this what that link does?

  3. #18
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    If you're using select(), you don't _need_ non-blocking.

    What ever you do, remember that TCP/IP provides data to your program as a byte stream, with as many breaks in it as it likes. By this I mean, a call to recv() could yield 1 byte of data, the next call another 3 bytes, and the next another 10. These 14 bytes together might make-up the user name supplied by send() in the client, but it's your job to concatenate them correctly.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #19
    Registered User
    Join Date
    Sep 2002
    Posts
    417
    thanks a bunch! This is going to make life easier!

    (the only "network" I knew how to do was put a text file and have it constantly read it... that would work some of the time... as long as everyone has read/write access to that file.)

  5. #20
    Registered User
    Join Date
    Jan 2003
    Posts
    99
    Ok...I have the screen name deal working now, in that it is sent but now Windows crashes when it is run.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM