Programming Question

thefish8

Senior member
Apr 17, 2001
291
0
0
What is a socket in C++?

I am trying to read incoming packets. How would I go about doing this and is using sockets a solution?

Thanks in advance.
 

dighn

Lifer
Aug 12, 2001
22,820
4
81
sockets are not part of C++ but rather part of the operating system. a socket is basically an abstract port that can send/receive data. in TCP/IP a socket would be bound to an IP and a port. the specifics of using sockets depend on your operating system though the general idea is the same.

are you trying to read UDP packets (datagrams) ? if so you can do it with sockets. and on what OS do you plan on doing this?
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
sockets are not part of C++ but rather part of the operating system. a socket is basically an abstract port that can send/receive data. in TCP/IP a socket would be bound to an IP and a port. the specifics of using sockets depend on your operating system though the general idea is the same.

Sockets are part of the C library although obviously part of the stack is implemented in each OSes kernel. And for basic socket usage, the functions are the same on all OSes that support C, i.e. socket, send,recv, accept, bind, connect, etc are all standard.
 

dighn

Lifer
Aug 12, 2001
22,820
4
81
Originally posted by: Nothinman
sockets are not part of C++ but rather part of the operating system. a socket is basically an abstract port that can send/receive data. in TCP/IP a socket would be bound to an IP and a port. the specifics of using sockets depend on your operating system though the general idea is the same.

Sockets are part of the C library although obviously part of the stack is implemented in each OSes kernel. And for basic socket usage, the functions are the same on all OSes that support C, i.e. socket, send,recv, accept, bind, connect, etc are all standard.

i don't believe sockets are part of the c standard library. it comes pretty standard though.

as for the usage, those functions are the mostly the same but on windows there are some extra set up calls that you need to make. windows also provides a lot support for asynchronous socket operations