0

I'm creating multicast server/client udp application in C in which server is sending data to multicast group of clients, and if data is not received, clients request for retransmission. I thought to create two sockets on server and client side. On server side one socket for sending multicast and another for receiving replies from clients. And on client side one socket for receiving data and another for reply back to server. What is confusing me is because socket is connected to multicast group...client join on that group with socket. Can I use two sockets and one multicast group or should I create two groups ? What is the most efficient solution? I can not have delays because it will be in real time...do you have some advice ?

Thx

user3119422
  • 87
  • 3
  • 11
  • 1
    i think you should use same socket for both sending message and getting acknowledgement. – Heena Goyal Mar 19 '14 at 06:48
  • Do you have some arguments why is not logical to use one socket for sending and another for receiving? What about multicast implementation if I decied for two sockets? Do you have experience? – user3119422 Mar 19 '14 at 07:10
  • yes i have hand with many standard protocols like 101 103 modbus. they are standards for communication and there is no second port defined for acknowledgement. and don't tell me then you will use third socket for data transfer – Heena Goyal Mar 19 '14 at 07:15
  • Do you need more threads one server side to process acknowledgement or one thread is enough? Why then some protocols like tftp use different port for sending and receiving? Sorry I'm confused... – user3119422 Mar 19 '14 at 07:21
  • don't be confused there would be two threads one is continuously writing on that socket and one is simultaneously reading the same socket. – Heena Goyal Mar 19 '14 at 07:24
  • I have problem with code if I call pthread_create with message processing function in while it works fine, I get messages from clients. But if I create pthread before while, and then in while call function for msg processing I don't receive nothing from clients ...int main(){ // arg structure has socket sd pthread_create(&cln_thread, NULL, msg_processing, (void *) &arg)) while(1){ sendto on broadcast IP msg_processing } } msg_processing (&arg) { recvfrom clients on the same socket as sending sd } – user3119422 Mar 19 '14 at 08:51

1 Answers1

0

On server side one socket for sending multicast and another for receiving replies from clients.

Definitely not.

And on client side one socket for receiving data and another for reply back to server.

Definitely not.

Peers will always want to respond back to the IP:port the request came from. If you add another port you add an endless configuration difficulty. If you only use one port it's easy. There is no performance or architectural reason to use two ports per process for this.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • And there is no disadvantages when using one sockets? I will have more clients and they all can send replies via just one sockets? Is it safe from server side to send continously data and in same time receives all those replies? Should server have more threads for proccessing replies ? – user3119422 Mar 19 '14 at 07:23
  • What part of 'there is no performance or architectural reason to use two ports' didn't you understand? – user207421 Mar 19 '14 at 08:55
  • The delay part , if I need real time application will processing with one socket and one thread have influence on delay? – user3119422 Mar 19 '14 at 09:36
  • I didn't say anything about one thread. Neither does your question. – user207421 Mar 19 '14 at 11:23