Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    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)

  2. #2
    Linux User cyberinstru's Avatar
    Join Date
    Jan 2007
    Yes, you can do it using send() from the server and sendto() from the client.

    in the packets i sent from client but it still dint work)
    I doubt, if packets with MF bit set are allowed out of the kernel???

    AFAIK, most of the routers, these days, don't permit fragmented packets.

    Please correct me, if I am wrong.
    Registered Linux User #440311

  3. #3

    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

  4. $spacer_open
  5. #4

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts