Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Write an article for LinuxForums Today! Win Great Prizes!
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > GNU Linux Zone > Linux Networking > Doubt regarding RAW sockets programming in C

Forgot Password?
 Linux Networking   Hardware/Software related, Modems, Internet connection sharing, IPTables etc.

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds
Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 03-05-2007   #1 (permalink)
Just 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)
chaitunv is offline  



Reply With Quote
Old 03-05-2007   #2 (permalink)
Linux User
 
cyberinstru's Avatar
 
Join Date: Jan 2007
Location: India
Posts: 352
Yes, you can do it using send() from the server and sendto() from the client.

Quote:
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
Forget what the World thinks...
Just follow your Heart...
---------------------------------
cyberinstru is offline   Reply With Quote
Old 03-05-2007   #3 (permalink)
Just 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
chaitunv is offline   Reply With Quote
Old 03-08-2007   #4 (permalink)
Just 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.
chaitunv is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
A Newbie's Getting Started Guide to Linux
Learn the basics of the Linux operating systems. Get to know what it is all about, and familiarize yourself with the practical side. Basically, if you're a complete Linux newbie and looking for a quick and easy guide to get you started this is it.
subscribe
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 10:09 PM.






© 2000 - - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.1