Results 1 to 4 of 4
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 03-05-2007 #1Just Joined!
- Join Date
- Feb 2006
- Posts
- 11
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)
- 03-05-2007 #2
Yes, you can do it using send() from the server and sendto() from the client.
I doubt, if packets with MF bit set are allowed out of the kernel???in the packets i sent from client but it still dint work)
AFAIK, most of the routers, these days, don't permit fragmented packets.
Please correct me, if I am wrong.---------------------------------
Registered Linux User #440311
HI2ARUN _AT_ GMAIL _DOT_ COM
---------------------------------
- 03-05-2007 #3Just Joined!
- Join Date
- Feb 2006
- Posts
- 11
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
- 03-08-2007 #4Just Joined!
- Join Date
- Feb 2006
- Posts
- 11
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.


Reply With Quote
