Doubt regarding RAW sockets programming in C
In a client-server scenario, with the client program using raw sockets ( int clientsock=socket(AF_INET, SOCK_RAW, IPPROTO_TCP))
and the server using stream sockets (int serversock= socket(AF_INET, SOCK_STREAM, IPPROTO_TCP))
Is it possible to send text messages to the server using send() or sendto() from the client?
If it is possible, My aim is to send 2 TCP fragments and read them as a single re-assembled packet on the server.
Please include C code if u can.
(i tried including IP header along with TCP header and pseudo header in the packets i sent from client but it still dint work)
Problem receiving packets sent through raw socket
Forget about TCP fragments. Im facing trouble sending/receving normal (unfragmented) packets themselves.
Do I have to 'connect' before sending a message (using sendto) to the server? - remember that iam using a raw socket for sending the packet from client.
If I call connect , the client program gives anerror saying "Transport endpoint already connected" --- although Iam calling connect just once.
If i dont, the client runs fine, but the server gives error at recv() function (i also tried recvfrom) saying "Transport end point NOT connected"
Remember that Iam using stream socket(not raw) for receiving on the server side
It works with UDP sockets but not with TCP
I think raw socket(using IPPROTO_TCP) to stream socket (SOCK_STREAM) communication isnt possible because of connection issues mentioned above. Although i have no idea why i got the "..endpoint already connected" error message
On the other hand, raw socket(using IPPROTO_UDP) to datagram sockets(SOCK_DGRAM) is possible because no connection is needed.