UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2014-07-24 10:52 AM

laurindamae
Member
Registered: 2014-07-24
Posts: 2
Website

Sock stream

Anyone may find this as elementary question but I'm confused with Sock Stream. What sock stream is and how it differs from AF_INET?

Offline

#2 2014-07-24 05:39 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,234

Re: Sock stream

AF_INET is the socket family (IPv4), SOCK_STREAM is the type of socket (TCP).

For UDP on IPv6 you'd use AF_INET6 and SOCK_DGRAM.

Basically the type says how the socket will behave (e.g. as a stream of bytes, or as messages), while the family says what kind of network will be used for transportation.

Offline

#3 2014-07-25 04:53 AM

laurindamae
Member
Registered: 2014-07-24
Posts: 2
Website

Re: Sock stream

I have UDP on IPv4. What socket is the right to use?

Offline

#4 2014-07-27 08:57 AM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,234

Re: Sock stream

IPv4 is AF_INET,
IPv6 is AF_INET6,

TCP is a SOCK_STREAM,
UDP is a SOCK_DGRAM.

For more info and detail, go read the socket and udp manpages. In a console type "man udp" and you'll get all info you need to create an UDP socket. If you don't have manpages, google for "man udp".

Offline

Board footer

Powered by FluxBB