jsan
jsan

Reputation: 1057

Sending data through UDP sockets

I'm able to setup a TCP connection between a client and a server, but just have a question about the setup for a UDP connection.

For TCP I used the following format

CLIENT                   SERVER
------                   ------
WSAStartup()             WSAStartup()
s=socket(x, y, z)        s=socket(x, y, z)
 -                       bind()
 -                       listen()
connect()                accept()
send()                    -
 -                       recv()
closesocket(s)           closesocket(s)
WSAcleanup()             WSACleanup()

Now my question is for the UDP setup. Since it is connectionless, would this be the right setup?

CLIENT                   SERVER
------                   ------
WSAStartup()             WSAStartup()
s=socket(x, y, z)        s=socket(x, y, z)
bind()                   bind()
sendto()                  -
 -                       recvfrom()
closesocket(s)           closesocket(s)
WSAcleanup()             WSACleanup()

Upvotes: 0

Views: 1260

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 598001

Yes, what you show is the correct setup for UDP.

Upvotes: 1

Related Questions