I'm looking forward to achive this: Server recieves from number of clients a string(file name) which he has to take from the folder and return it to the the client by a bufferSize which is defined from the command line. It has to be implemented with UDP communication. i'm familiarized with TCP sockets, but i don't get how can i get a fileDescriptor for the udp connection since accepts is missing.
So I'm thinking about this: after the config i do a while-loop in the server where i get 'some kind of descriptor' which i'll send to a new thread which knows where to send the data back... Any ideas?
I've checked the net but didn't found a concrete explanation for this kind of operation.
You don't get connections with UDP; you use sendto()
and recvfrom()
to send and receive messages.
So the server will call recvfrom()
on the socket; unwrap the request from the data it receives, do the appropriate actions, and use sendto()
to send the response back to the client from which the request was received.
The client will call sendto()
to package a message to the server, and then call recvfrom()
to get the response. Note that UDP is an unreliable protocol; there is no guarantee that each message will be delivered. The client has to implement timeouts in case the server dropped a UDP request. Servers have to be able to deal with duplicate requests, too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With