I want to write a server such that it receives UDP and TCP messages on same port continuously.
I have created 2 sockets tcpsock, udpsock. I am binding them to same port by using (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one)) < 0) function.
Now if i want to receive messages on both of these sockets..
while(1) {
newsock = accept(tcpsock, (struct sockaddr*)&sin, &sinlen);
recv(newsock, buffer, MAXBUFF-1, 0))== -1);
recvfrom(udpsock, buffer, MAXBUFF-1, 0, (struct sockaddr*)&sin, &sinlen))== -1);
}
is this possible? if possible, how these sockets differentiate messages like udp messages and tcp messages? will there be any conflict? or is there any other possibility to do this?
Thanks,
Kiran