Network programming @ Noppa | @ wiki - Updated: — Jussi Laakkonen 2012/08/29 11:41

Example codes

Some example codes for your use.

Hello World!

Unpack: helloworld.tar.gz

  • Creates a directory “helloworld”
  • See README-file in helloworld -directory

SCTP example

2012 version sctp_demo2012.tar.gz

2011 version (old) sctp_demo.tar.gz

Required packages for Debian/Ubuntu (same for other distros?) to develop applications on top of SCTP: libsctp-dev, libsctp1.

Build with:

# Build client and server (all)
# Build client and server with debug enabled
make debug
# Build test client and server
make tests

To run:

# Server: give port and some of the following (optional):
# addrinfo - use getaddrinfo(), i.e. use passive addresses (any)
# ifaddrs - [default] use getifaddrs(), use the actual addresses from running interfaces
# combine - Use first ifaddrs() to get all of the addresses then use getnameinfo() and getaddrinfo() to fill structs
./testsctps <port> <addrinfo|ifaddrs|combined>
# Client: give IP/hostname and port
./testsctpc <IP|host> <port>

TCP example

Unpack tcpexample2012.tar.gz

  • Creates a folder tcpexample
  • build with make
  • Run:
    • Server (starts at port 6543)
    • Client
      ./tcpclient -h <host/IP> -p <port>

UDP client and server


  • 2012 udpexample2012.tar.gz New function usage
  • OLD udpexample.tar.gz Note: uses old functions, example will be updated soon
  • creates a folder “udpexample”
  • build with make
  • Run
    • Server
      ./udpexample <port>
    • Client
      ./udpexample <port> <IP>

Ncurses game example