🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Just tell me, please

Started by
1 comment, last by GameDev.net 24 years, 8 months ago
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 =)


Advertisement
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
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.

This topic is closed to new replies.

Advertisement