Re: How to format/send/receive UDP packet in C?

R

Rahul Gandhi

I'd like to ask about how to format/send/receive UDP datagram packet
in C language. The server that I'd like to send the packet to is
listening on port 1500. When I succesfully connect to that port, it's
gonna create and send a packet back to the client. The only code I
need to write is the client-side code. The problem is, I don't have
any idea how to:

1. Send data packet to server (I'm going to send the data in Hex
format)
2. Receive data back from that server

I also don't have any idea how to format the packet. Please give me a
simple explanation. Thank you so much.

PS. I searched for example code, but I got only the one that show me
how to send packet to server. No code show me how to also receive the
packet.


The code for sending and recieving the UDP packets is in Unix network
Programming by Richard Stevens.
UDP Packet Format.
------------- 32 bits --------
| Source Port | Dest Port |
---------------------------------
| Udp Msg Length | UDP Checksum |
----------------------------------
| UDP payload |
| |
| |
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top