- From: Thomas Dreibholz <dreibh AT exp-math.uni-essen.de>
- To: "Sumathi.Elangovan" <Sumathi.Elangovan AT uk.thalesgroup.com>
- Cc: "'discussion AT sctp.de'" <discussion AT sctp.de>
- Subject: [SCTP-Discussion] Re: "C" examples!!!
- Date: Wed Oct 30 13:22:02 2002
- List-id: SCTP Discussions <discussion.sctp.de>
- Organization: University of Essen, Institute for Experimental Mathematics
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Am Mittwoch, 30. Oktober 2002 12:53 schrieben Sie:
>
Hi! Thanks for your help! I did try the server-client example within the
>
"cppsocket_program" and it works perfectly at the "command prompt" and the
>
"ide-Kdevelop 1.4". I did look into the "c" examples... and there is only a
>
server side examples available..."TCP_combined_server" and
>
"idexampletcp"...is there a client side example available. Does the
>
examples within the socket_programs implement association and data
>
transfer? If I do need to develop the client side...would it be better to
>
use the "TCP_combined_server" than "idexampletcp". I got a better
>
knowledge in "c" than "c++" and I would like to develop my application in
>
"c". Thanks for your help.
TCP_combined_server is a C version of the C++ program "sctpmultiserver".
Currently, there is no C version of "sctpterminal". But writing an
application which simply establishes a connection to the server and sends
data is easy:
struct sockaddr_in remote_addr;
char* data = "This is a test!\n";
if ((fd = ext_socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP)) < 0) {
perror("ext_socket");
exit(1);
}
/* prepare remote address */
bzero(&remote_addr, sizeof(remote_addr));
#if !defined (LINUX)
remote_addr.sin_len = sizeof(remote_addr);
#endif
remote_addr.sin_family = AF_INET;
if (inet_aton("<Insert IP Address of your server
here!>",&remote_addr.sin_addr) != 1)
printf("inet_aton failed");
exit(1);
}
remote_addr.sin_port = htons(9); // <- Port 9 = Discard Service
if(ext_connect(fd, (const struct sockaddr
*)&remote_addr,sizeof(remote_addr)) < 0) {
perror("ext_connect");
exit(1);
}
// Here, your association has been established and you can send data
for(i = 0;i < 10;i++) {
if(ext_write(fd,data,strlen(data)) < 0) {
perror("ext_write failed!");
exit(1);
}
}
if (ext_close(fd) < 0)
perror("ext_close");
}
Using discard service (port 9), the server simply discards your data. Echo
(port 7) would echo it back.
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.0.6 (GNU/Linux)
Comment: For info see
http://www.gnupg.org
iD8DBQE9v81432BbsHYPLWURAtQLAJ9gFY4htuLkYBVmjXoA4ZDXpdMEGACg2dBZ
xGUZy1TVzLJNiudnGNgMWrM=
=Ie7G
-----END PGP SIGNATURE-----
Archive powered by MHonArc 2.6.19+.