Computer Science Canada

Sockets?...Libraries!

Author:  Apage43 [ Sat Nov 22, 2003 7:10 pm ]
Post subject:  Sockets?...Libraries!

What's a good socket library for C++?
If not cross-platform, *nix compatible, please.

Author:  Dan [ Sun Nov 23, 2003 2:50 pm ]
Post subject: 

plz post in the right fourm, moved....

any how some compilers come with a winsock libeary. but that only wroks with windows.

here is a tutoiral on it:

http://www.madwizard.org/view.php?page=tutorials.networking.contents&lang=cpp

and here

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=2241&lngWId=3

i do bivle that some compilers also come with a verson for unix/linux.

Author:  wtd [ Tue Apr 06, 2004 10:04 pm ]
Post subject: 

This might be better done in a higher level language, too. Perl, Python, Ruby... any of those will give you socket capabilities that will work pretty much anywhere. And the code's heaven too. Smile

code:
require "socket"

$port = 12000

server = TCPServer.new($port);

Thread.start(server.accept) { |client|
   client.puts("hello world!")
   client.close
}

client = TCPSocket.new("localhost", $port)
puts client.gets


A simple server (only accepts one connection) and a client in 13 lines of code that will work on *nix (Linux, BSDs, Mac OS X, Solaris, AIX, etc.) and Windows.

Anyway, just a thought.


: