SCTP Discussions

Text archives Help


Re: [SCTP-Discussion] Non-blocking mode for the sctp socket api


Chronological Thread 
  • From: Pablo Salinas <pablopesb AT yahoo.com>
  • To: Thomas Dreibholz <dreibh AT exp-math.uni-essen.de>
  • Cc: discussion AT sctp.de
  • Subject: Re: [SCTP-Discussion] Non-blocking mode for the sctp socket api
  • Date: Tue Jul 29 21:42:01 2003
  • List-id: SCTP Discussions <discussion.sctp.de>

Hi Thomas,
              Thanks for you help. I have another question:
A SCTP association is a full duplex channel, rigth?
So, I could write an application (server) that establishes an association and then forks. The father process than continuously sends data, while the child process reads data from the same IP address:Port.
Example:
/* Server */
ext_socket
ext_bind
ext_listen
ext_accept
fork
/* father process */
ext_send
/* child process */
ext_read
 
/* Client */
ext_socket
ext_connect
fork
/* father process */
ext_read
/* child process */
ext_send
 
Because, I have tried it (non-blocking mode), but it didn't work.
 
thanks again,
                    Pablo S.

Thomas Dreibholz <dreibh AT exp-math.uni-essen.de> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am Dienstag, 22. Juli 2003 17:37 schrieb Pablo Salinas:
> Hi there,
> I am interested in knowing more about the
> non-blocking mode of the sctp socket api. I need to
> write an application that stablish a sctp association
> with another machine. After that, it must send and
> receive data messages through that sctp association.
> But, the thing is, that it should be able to send and
> receive sctp messages at any given time.
> First question: Does the non-blockin mode work only
> for the UDP-like socket api?
> Or does it work for both, the UDP and TCP styles?

Of couse it works for both, UDP and TCP style.


> Second of all, can anyone send me an example code? It
> doesn't need to be a working code. Just one that will
> give me an idea of the function calls that should be
> made in both sides (the client and server)and the
> order of these function calls.

Just set the flag O_NONBLOCK using ext_fcntl(). The following functions
(copied from the rsplib code) show how to set and unset the non-blocking mode
for a given socket "fd":

/* ###### Set non-blocking mode ########################################## */
bool setBlocking(int fd)
{
int flags = ext_fcntl(fd,F_GETFL,0);
if(flags != -1) {
flags &= ~O_NONBLOCK;
if(ext_fcntl(fd,F_SETFL,flags) == 0) {
return(true);
}
}
return(false);
}


/* ###### Set blocking mode ############################################## */
bool setNonBlocking(int fd)
{
int flags = ext_fcntl(fd,F_GETFL,0);
if(flags != -1) {
flags |= O_NONBLOCK;
if(ext_fcntl(fd,F_SETFL,flags) == 0) {
return(true);
}
}
return(false);
}


For your program, you can probably do the following:
- - Establish SCTP association, socket fd
(Server: ext_bind()/ext_bindx(), ext_listen(), ext_accept()
Client: ext_connect()/ext_connectx()
- - setNonBlocking(fd)
- - ext_select() loop

For examples how to use select, also see the sources of the rsplib
distribution (also under http://www.sctp.de), especially examplepe.c and
examplepu.c. There are also various TCP and UDP examples in the Internet.


Best regards
- --
=======================================================================
Dipl.-Inform. Thomas Dreibholz

University of Essen, Room ES210
Inst. for Experimental Mathematics Ellernstraße 29
Computer Networking Technology Group D-45326 Essen/Germany
- -----------------------------------------------------------------------
E-Mail: dreibh AT exp-math.uni-essen.de
Homepage: http://www.exp-math.uni-essen.de/~dreibh
=======================================================================
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/IP3k32BbsHYPLWURAu6EAJwPPmna9UMAxnGPEyDz21jJXmldhACgih46
_on3XOMGz6B9DFZexfWDDMqI_=
=pbbq
-----END PGP SIGNATURE-----

_______________________________________________
discussion mailing list
discussion AT sctp.de
http://www.sctp.de/mailman/listinfo/discussion



Do You Yahoo!?
Todo lo que quieres saber de Estados Unidos, América Latina y el resto del Mundo.
Visíta Yahoo! Noticias.



Archive powered by MHonArc 2.6.19+.

Top of page