htonl, htons, ntohl, ntohs - convert values between host and network byte order
netlong = htonl(hostlong);
u_long netlong, hostlong;
netshort = htons(hostshort);
u_short netshort, hostshort;
hostlong = ntohl(netlong);
u_long hostlong, netlong;
hostshort = ntohs(netshort);
u_short hostshort, netshort;
These routines convert 16 and 32 bit quantities between network byte order and host byte order. On machines such as the SUN these routines
are defined as null macros in the include file <netinet/in.h>.
These routines are most often used in conjunction with Internet addresses and ports as returned by gethostbyname(3N) and getservent(3N).
SEE ALSO gethostbyname(3N), getservent(3N)BUGS
The VAX handles bytes backwards from most everyone else in the world. This is not expected to be fixed in the near future.
4.2 Berkeley Distribution May 15, 1986 BYTEORDER(3N)
Check Out this Related Man Page
BYTEORDER(3) BSD Library Functions Manual BYTEORDER(3)NAME
htonl, htons, ntohl, ntohs -- convert values between host and network byte order
Standard C Library (libc, -lc)
These routines convert 16 and 32 bit quantities between network byte order and host byte order. On machines which have a byte order which is
the same as the network order, routines are defined as null macros.
These routines are most often used in conjunction with Internet addresses and ports as returned by gethostbyname(3) and getservent(3).
SEE ALSO gethostbyname(3), getservent(3), byteorder(9)STANDARDS
The byteorder functions conform to IEEE Std 1003.1-2001 (``POSIX.1'').
The byteorder functions appeared in 4.2BSD.
On the VAX bytes are handled backwards from most everyone else in the world. This is not expected to be fixed in the near future.
BSD March 20, 2005 BSD
I having an issue while compiling a C program in USS (z/OS) machine.
I was able to create objest files (.o) from source (.c) files but when I try to create a binary file from the object files I am getting the below error.
$ cc util.o sock.o app.o -lnsl -o ptf
FSUM3067 The archive... (7 Replies)
I have created a UDP multicast transmitter and receiver, first using windows. But now I need the receiver to run on Ubuntu 10.04.
The code is the following:
/************************** Receiver *************************/
// Module Name: Receiver.c
// ... (0 Replies)
Ok so this is what I have.
I have separate client and server codes. I initially had the server listening and accepting connections from ONE port, and it was working great.
Now, what I want to do is, enable the server to listen and accept connections on TWO OR MORE ports , thus, effectively... (2 Replies)
my issue is - I have people connecting to my hosts from the outside world (for POC testing). There application listens on a port 3010 which is bound to the localhost. Using netstat -an | grep LISTEN it is the only port that is bound - ie: ftp, ssh etc listen on all interfaces. I need... (1 Reply)
Hi all, is it possible to use a different port number for daytime service. By default the port number of daytime service is 13, so what if I want to get the time from a different port number e.g say 9000 (or any other port).
I guess this would remain the same on the server side !... (2 Replies)
I have a simple client/server program I am using for learning purposes.
I have it setup so that after server is setup and listening it than goes into a loop where it accepts incoming client connections. After each connection, the client socket is than passed to a thread routine where it can be... (3 Replies)
I am getting error in bind function of "Address already in use" even also i have used the setsockopt function in that case .
int ret = 0;
int listenSock = 0;
struct sockaddr_in myAddr;
struct sockaddr_in ... (1 Reply)
I have posted several times regarding my application.
In a nutshell, I have a server application that logs attached instrument data over USB and Ethernet. My restriction here is having two wires or more to plug all instrumentation in - at least one for USB and at least one for ethernet.
... (16 Replies)
Sorry for the “word salad” subject, but I wanted to cast a wide net for help.
I've created an IP (Internet Protocol) server which serves HTTP, SMTP, and FTP requests.
As you probably know, they all require creating a socket, listening on it, accepting connections, and then having a short... (3 Replies)
Hi all, I'm new programming in C, so I had the next message in my code:
Dual.c:88:20: warning: pointer type mismatch in conditional expression : &clientSa.sin6.sin6.sin6_addr,
Any help would be great
#include... (1 Reply)
I'm trying to make a "dual/server client" (ipv4,ipv6) with sockets in linux but i don't know how to join both codes. I have a dual client ipv4 and ipv6, but i have problems with the server if you notice the only difference between them it's the AF_INET (pf_inet ipv4, and if_inet6 ipv6) and the port... (3 Replies)
I am setting the socket option SO_BINDTODEVICE for eth0 to be able to route the packets only through that interface. However, bind() fails with "Port already in use" error with this option when the server is restarted despite having the socket option SO_REUSEADDR.
Here is my code snippet:
... (0 Replies)