• Advertisement

Archived

This topic is now archived and is closed to further replies.

Guest Anonymous Poster

Just tell me, please

This topic is 6781 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

the other side has to create a socket, bind it to a port, and then use recv to recieve data if it's using UDP. if you're using TCP, you have to do something like listen and then accept before recieving. you can send the data in any format you want.

oh, and you are on the right track =)

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
I am trying to write a program that uses winsock. I have asked many many people so many times how to do this and no one will give me a straight answer, so all I want to know is if I'm on the right course.
I think what I need to do is #include
then insert the code something like
connect( *host )
sendto( *host )
then put here whatever I want to send, am I even on the right track?
and if this is right, how do i get the other side to receive it, and how exactly should I send the info that I want to send?
Thanks in advance

Share this post


Link to post
Share on other sites
Derek,

You are on the right track, but before you go too much further you might want to sort out in your mind what you intend to do.

Winsock allows socket communication in two basic modes.

Datagram sockets
Stream sockets

Both of these types have benefits and disadvantages.

Stream sockets are point-to-point. One end of the connection is the client, who uses connect() to connect to the server. The server uses listen() to listen for connections, and accept() to accept the connection from the client. From there, they both use send() and recv() to send and recieve data in a stream. By stream, I mean one character after another. All data is guaranteed to get from client to server and vice versa in the order it went out. This is an important distinction since..

Datagram sockets are different. Datagram sockets do not require the connect, listen() and accept() scheme, and can really just be used with sendto() and recvfrom(). In truth, though, you still need to use bind() to get the server to bind to a port. This is used to stablize the network transactions. The other differences of datagram sockets are that they don't send in streams. They send one packet of a user definable size each time, and are not guaranteed to ever reach the destination, nor to reach the destination in any order. That is to say, if you sendto("packet a"), then sendto("packet b"), you might get packet B before packet A, or packet B may never arrive. In actuallity, not that many packets do go missing, I find, but I might be lucky.

Some additional information from a good book can be found online at:
http://www.sockets.com/

I hope that helps.

Share this post


Link to post
Share on other sites

  • Advertisement