LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 06-03-2008, 01:38 AM   #1
libinmeledam
LQ Newbie
 
Registered: Apr 2008
Posts: 4

Rep: Reputation: 0
Unhappy socket programing - using message boundaries


Can anyone tel me how to use SOCK_SEQPACKET ..
I mean how to create a socket which maintains message boundaries...

now i am usning sock=socket(AF_INET,SOCK_STREAM,0))to create a socket
but this socket donot maintain message boundaries.. in the sense if we do a recv() function after sender has send two messages(using send), these two will be considerd as one in the receiver side.
That is, one call to recv() will fetch both the messages send using 2calls to send()...
I donot need this. i need each message to be identified seperately

Please help... i need it urgently...
 
Old 06-03-2008, 06:17 AM   #2
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
You can abuse OpenSSL for that. Otherwise I don't know of any protocol stacks that would do it for you; it's the sort of thing that's a high enough level that I wouldn't expect a standard system library to have it.
 
Old 06-03-2008, 05:17 PM   #3
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
Quote:
Originally Posted by pinniped View Post
it's the sort of thing that's a high enough level that I wouldn't expect a standard system library to have it.
On the contrary, this is exactly what SCTP does!

The OP asked for help in using SCTP, in which case I would ask him/her where he/she is stuck. The SOCK_SEQPACKET is a standard extension to the Berkley Sockets API. Whereas one uses send() and recv() for SOCK_STREAM, sendto() and recvfrom() for SOCK_DGRAM, the canonical functions for SOCK_SEQPACKET are sendmsg() and recvmsg().

For the *msg() functions, you will need to populate a special structure of type “struct msghdr”. This is all explained in the manpages (or at least in any primer on SCTP sockets).

Btw, here is the definitive “standard” on the SCTP socket API.
 
Old 06-03-2008, 06:02 PM   #4
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
Ah, ok. I guess there's yet another socket protocol for me to learn.
 
Old 06-03-2008, 06:48 PM   #5
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
I forgot to mention that you don’t have to use SOCK_SEQPACKET for SCTP if you don’t want. SOCK_STREAM is also supported (as long as you specify the correct protocol).
 
  


Reply

Tags
sockets


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
message size TCP socket ibanezul Linux - Networking 2 10-23-2007 04:07 PM
I need some socket programing in C help tomazN Programming 6 12-08-2005 11:35 AM
Raw Socket Programing djgerbavore Programming 2 08-18-2004 12:58 PM
How to broascast a message using socket API in linux with C dileepkk Linux - Networking 0 07-21-2004 04:54 AM
Are there proper partition block boundaries? GrumpyGnome Linux - Software 0 06-01-2004 03:34 PM


All times are GMT -5. The time now is 12:16 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration