<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-9166134204259279359</id><updated>2024-08-29T16:42:07.642-07:00</updated><category term="accept"/><category term="bind"/><category term="socket"/><category term="c/c++"/><category term="client"/><category term="close"/><category term="connect"/><category term="functions"/><category term="host"/><category term="ip address"/><category term="server"/><category term="socket programming c/c++ structures struct network unix"/><category term="steps"/><title type='text'>C programming</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://letuscodeinc.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9166134204259279359/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://letuscodeinc.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ghost Henry</name><uri>http://www.blogger.com/profile/08996728742859917234</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>8</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-9166134204259279359.post-5624859387317864363</id><published>2013-10-01T23:32:00.002-07:00</published><updated>2013-10-01T23:32:14.682-07:00</updated><title type='text'>Embedupload</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Embedupload is one of the most useful uploading service which i have came across. It allows person to upload files to many servers in very less time as well as allows us to save our bandwidth. I will recommend it to all my viewers.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://letuscodeinc.blogspot.com/feeds/5624859387317864363/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://letuscodeinc.blogspot.com/2013/10/embedupload.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9166134204259279359/posts/default/5624859387317864363'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9166134204259279359/posts/default/5624859387317864363'/><link rel='alternate' type='text/html' href='http://letuscodeinc.blogspot.com/2013/10/embedupload.html' title='Embedupload'/><author><name>Ghost Henry</name><uri>http://www.blogger.com/profile/08996728742859917234</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9166134204259279359.post-6216371045087985014</id><published>2011-05-20T08:45:00.000-07:00</published><updated>2011-05-20T08:45:48.181-07:00</updated><title type='text'>Steps involved in creating a client</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Following are the major steps involved in creating a client:&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Create a socket with the socket() system call&lt;/li&gt;
&lt;li&gt;Connect the socket to the address of the server using the connect() system call&lt;/li&gt;
&lt;li&gt;Send and receive data. There are a number of ways to do this, but the simplest is to use the read() and write() system calls.&lt;br /&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://letuscodeinc.blogspot.com/feeds/6216371045087985014/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://letuscodeinc.blogspot.com/2011/05/steps-involved-in-creating-client.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9166134204259279359/posts/default/6216371045087985014'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9166134204259279359/posts/default/6216371045087985014'/><link rel='alternate' type='text/html' href='http://letuscodeinc.blogspot.com/2011/05/steps-involved-in-creating-client.html' title='Steps involved in creating a client'/><author><name>Ghost Henry</name><uri>http://www.blogger.com/profile/08996728742859917234</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9166134204259279359.post-3872509684981928662</id><published>2011-05-20T08:41:00.000-07:00</published><updated>2011-05-20T08:41:30.066-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="accept"/><category scheme="http://www.blogger.com/atom/ns#" term="bind"/><category scheme="http://www.blogger.com/atom/ns#" term="server"/><category scheme="http://www.blogger.com/atom/ns#" term="socket"/><category scheme="http://www.blogger.com/atom/ns#" term="steps"/><title type='text'>Steps involved in creating a server</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Following are the major steps involved in creating a &amp;nbsp;server:&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Create a socket with the socket() system call&lt;/li&gt;
&lt;li&gt;Bind the socket to an address using the bind() system call. For a server socket on the Internet, an address consists of a port number on the host machine.&lt;/li&gt;
&lt;li&gt;Listen for connections with the listen() system call&lt;/li&gt;
&lt;li&gt;Accept a connection with the accept() system call. This call typically blocks until a client connects with the server.&lt;/li&gt;
&lt;li&gt;Send and receive data&lt;br /&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://letuscodeinc.blogspot.com/feeds/3872509684981928662/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://letuscodeinc.blogspot.com/2011/05/steps-involved-in-creating-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9166134204259279359/posts/default/3872509684981928662'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9166134204259279359/posts/default/3872509684981928662'/><link rel='alternate' type='text/html' href='http://letuscodeinc.blogspot.com/2011/05/steps-involved-in-creating-server.html' title='Steps involved in creating a server'/><author><name>Ghost Henry</name><uri>http://www.blogger.com/profile/08996728742859917234</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9166134204259279359.post-1796006072491640561</id><published>2011-05-18T12:36:00.000-07:00</published><updated>2011-05-18T12:36:28.407-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="client"/><category scheme="http://www.blogger.com/atom/ns#" term="connect"/><category scheme="http://www.blogger.com/atom/ns#" term="host"/><category scheme="http://www.blogger.com/atom/ns#" term="ip address"/><title type='text'>Code for finding Ip address of server</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;#include &amp;lt;stdio.h&amp;gt;          /*using for printf*/&lt;br /&gt;
#include &amp;lt;netdb.h&amp;gt;          /*used for gethostbyname() function*/&lt;br /&gt;
#include &amp;lt;sys/types.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; struct hostent *he;/*making a structure to hold all the info related to host like hostname and host ip*/&lt;br /&gt;
&amp;nbsp; if (argc!=2)/*if no arguments are passed*/&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;    argv[1]=&quot;www.google.com&quot;;/*then make www.google.com as our default option*/&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; he=gethostbyname(argv[1]);/*fills the he structure instance with hostname and ip address*/&lt;br /&gt;
&amp;nbsp; if (he==NULL)/*if he is NULL that means the host is not found*/&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;    printf(&quot;gethostbyname() error\n&quot;);&lt;br /&gt;
&amp;nbsp;    exit(-1);/*exit the program with error*/&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; printf(&quot;Hostname : %s\n&quot;,he-&amp;gt;h_name);  /* prints the hostname */&lt;br /&gt;
&amp;nbsp; /*inet_ntoa converts string IP addresses to long*/&lt;br /&gt;
&amp;nbsp; printf(&quot;IP Address: %s\n&quot;,inet_ntoa(*((struct in_addr *)he-&amp;gt;h_addr))); /* prints IP address */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://letuscodeinc.blogspot.com/feeds/1796006072491640561/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://letuscodeinc.blogspot.com/2011/05/code-for-finding-ip-address-of-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9166134204259279359/posts/default/1796006072491640561'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9166134204259279359/posts/default/1796006072491640561'/><link rel='alternate' type='text/html' href='http://letuscodeinc.blogspot.com/2011/05/code-for-finding-ip-address-of-server.html' title='Code for finding Ip address of server'/><author><name>Ghost Henry</name><uri>http://www.blogger.com/profile/08996728742859917234</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9166134204259279359.post-3115817364455721268</id><published>2011-05-15T13:58:00.000-07:00</published><updated>2011-05-15T13:58:26.390-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="accept"/><category scheme="http://www.blogger.com/atom/ns#" term="bind"/><category scheme="http://www.blogger.com/atom/ns#" term="c/c++"/><category scheme="http://www.blogger.com/atom/ns#" term="close"/><category scheme="http://www.blogger.com/atom/ns#" term="functions"/><category scheme="http://www.blogger.com/atom/ns#" term="socket"/><title type='text'>IMPORTANT FUNCTIONS</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;I will mention some of the important functions used in socket programming and which header files to include in your program:&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;socket()&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;#include &amp;lt;sys/types.h&amp;gt;&lt;br /&gt;
&amp;nbsp;#include &amp;lt;sys/socket.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;int socket(int domain,int type,int protocol);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Let&#39;s see the arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; domain   -&amp;gt; you can set &quot;AF_INET&quot; (set AF_INET to use ARPA internet protocols)&lt;br /&gt;
&amp;nbsp;      or &quot;AF_UNIX&quot; if you want to create sockets for inside comunication.&lt;br /&gt;
&amp;nbsp;      Those two are the most used, but don&#39;t think that there are just &lt;br /&gt;
&amp;nbsp;        those. There are more I just don&#39;t mention them. &lt;br /&gt;
&amp;nbsp; type     -&amp;gt; here you put the kind of socket you want (Stream or Datagram)&lt;br /&gt;
&amp;nbsp;        If you want Stream Socket the type must be SOCK_STREAM&lt;br /&gt;
&amp;nbsp;        If you want Datagram Socket the type must be SOCK_DGRAM&lt;br /&gt;
&amp;nbsp; protocol -&amp;gt; you can just set protocol to 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;socket() gives you a socket descriptor that you can use in later system calls or&lt;br /&gt;
&amp;nbsp;it gives you -1 on error (this is usefull for error checking routines).&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;bind()&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;#include &amp;lt;sys/types.h&amp;gt;&lt;br /&gt;
&amp;nbsp;#include &amp;lt;sys/socket.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;int bind(int fd, struct sockaddr *my_addr,int addrlen);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Let&#39;s see the arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; fd  -&amp;gt; is the socket file descriptor returned by socket() call&lt;br /&gt;
&amp;nbsp; my_addr -&amp;gt; is a pointer to struct sockaddr&lt;br /&gt;
&amp;nbsp; addrlen -&amp;gt; set it to sizeof(struct sockaddr)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;bind() is used when you care about your local port (usually when you use listen() ) &lt;br /&gt;
&amp;nbsp;and its function is to associate a socket with a port (on your machine). It returns &lt;br /&gt;
&amp;nbsp;-1 on error.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;You can put your IP address and your port automatically:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; server.sin_port = 0;          /* bind() will choose a random port*/&lt;br /&gt;
&amp;nbsp; server.sin_addr.s_addr = INADDR_ANY;  /* puts server&#39;s IP automatically */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;An important aspect about ports and bind() is that all ports bellow 1024 are reserved.&lt;br /&gt;
&amp;nbsp;You can set a  port above 1024 and bellow 65535 (unless the ones being used by other&lt;br /&gt;
&amp;nbsp;programs).&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;connect()&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;#include &amp;lt;sys/types.h&amp;gt;&lt;br /&gt;
&amp;nbsp;#include &amp;lt;sys/socket.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;int connect(int fd, struct sockaddr *serv_addr, int addrlen);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Let&#39;s see the arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; fd    -&amp;gt; is the socket file descriptor returned by socket() call&lt;br /&gt;
&amp;nbsp; serv_addr -&amp;gt; is a pointer to struct sockaddr that contains destination IP&lt;br /&gt;
&amp;nbsp;       address and port&lt;br /&gt;
&amp;nbsp; addrlen   -&amp;gt; set it to sizeof(struct sockaddr)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;connect() is used to connect to an IP address on a defined port. It returns -1 on&lt;br /&gt;
&amp;nbsp;error.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;strong&gt;listen()&lt;/strong&gt;&lt;br /&gt;
&amp;nbsp;#include &amp;lt;sys/types.h&amp;gt;&lt;br /&gt;
&amp;nbsp;#include &amp;lt;sys/socket.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;int listen(int fd,int backlog);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Let&#39;s see the arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; fd  -&amp;gt; is the socket file descriptor returned by socket() call&lt;br /&gt;
&amp;nbsp; backlog -&amp;gt; is the number of allowed connections&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;listen() is used if you&#39;re waiting for incoming connections, this is, if you want&lt;br /&gt;
&amp;nbsp;someone to connect to your machine. Before calling listen(), you must call bind()&lt;br /&gt;
&amp;nbsp;or you&#39;ll be listening on a random port =) After calling listen() you must call&lt;br /&gt;
&amp;nbsp;accept() in order to accept incoming connection. Resuming, the sequence of system calls&lt;br /&gt;
&amp;nbsp;is:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 1. socket()&lt;br /&gt;
&amp;nbsp; 2. bind()&lt;br /&gt;
&amp;nbsp; 3. listen()&lt;br /&gt;
&amp;nbsp; 4. accept() /* In the next section I&#39;ll explain how to use accept() */&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;As all functions above described, listen() returns -1 on error.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;accept()&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;#include &amp;lt;sys/socket.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;int accept(int fd, void *addr, int *addrlen);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Let&#39;s see the arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; fd  -&amp;gt; is the socket file descriptor returned by listen() call&lt;br /&gt;
&amp;nbsp; addr    -&amp;gt; is a pointer to struct sockaddr_in where you can determine which host&lt;br /&gt;
&amp;nbsp;     is calling you from which port&lt;br /&gt;
&amp;nbsp; addrlen -&amp;gt; set it to sizeof(struct sockaddr_in) before its address is passed&lt;br /&gt;
&amp;nbsp;     to accept()&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&amp;nbsp;send()&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; int send(int fd,const void *msg,int len,int flags);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Let&#39;s see the arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; fd -&amp;gt; is the socket descriptor where you want to send data to&lt;br /&gt;
&amp;nbsp; msg    -&amp;gt; is a pointer to the data you want to send&lt;br /&gt;
&amp;nbsp; len    -&amp;gt; is the length of the data you want to send (in bytes)&lt;br /&gt;
&amp;nbsp; flags  -&amp;gt; set it to 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;This function is used to send data over stream sockets or CONNECTED datagram sockets.&lt;br /&gt;
&amp;nbsp;If you want to send data over UNCONNECTED datagram sockets you must use sendto().&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;send() returns the number of bytes sent out and it will return -1 on error.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;recv()&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;int recv(int fd, void *buf, int len, unsigned int flags);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Let&#39;s see the arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; fd  -&amp;gt; is the socket descriptor to read from&lt;br /&gt;
&amp;nbsp; buf -&amp;gt; is the buffer to read the information into&lt;br /&gt;
&amp;nbsp; len  -&amp;gt; is the maximum length of the buffer&lt;br /&gt;
&amp;nbsp; flags  -&amp;gt; set it to 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;As I said above about send(), this function is used to send data over stream sockets or&lt;br /&gt;
&amp;nbsp;CONNECTED datagram sockets. If you want to send data over UNCONNECTED datagram sockets&lt;br /&gt;
&amp;nbsp;you must use recvfrom().&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;recv() returns the number of bytes read into the buffer and it&#39;ll return -1 on error.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;sendto()&lt;/strong&gt;&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp;int sendto(int fd,const void *msg, int len, unsigned int flags,&lt;br /&gt;
&amp;nbsp;    const struct sockaddr *to, int tolen);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Let&#39;s see the arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; fd  -&amp;gt; the same as send()&lt;br /&gt;
&amp;nbsp; msg     -&amp;gt; the same as send()&lt;br /&gt;
&amp;nbsp; len -&amp;gt; the same as send()&lt;br /&gt;
&amp;nbsp; flags -&amp;gt; the same as send()&lt;br /&gt;
&amp;nbsp; to -&amp;gt; is a pointer to struct sockaddr&lt;br /&gt;
&amp;nbsp; tolen -&amp;gt; set it to sizeof(struct sockaddr)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;As you can see, sendto() is just like send(). It has only two more arguments : &quot;to&quot;&lt;br /&gt;
&amp;nbsp;and &quot;tolen&quot; =)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;sendto() is used for UNCONNECTED datagram sockets and it returns the number of bytes&lt;br /&gt;
&amp;nbsp;sent out and it will return -1 on error.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;recvfrom()&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;int recvfrom(int fd,void *buf, int len, unsigned int flags&lt;br /&gt;
&amp;nbsp;      struct sockaddr *from, int *fromlen);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Let&#39;s see the arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; fd -&amp;gt; the same as recv()&lt;br /&gt;
&amp;nbsp; buf -&amp;gt; the same as recv()&lt;br /&gt;
&amp;nbsp; len -&amp;gt; the same as recv()&lt;br /&gt;
&amp;nbsp; flags -&amp;gt; the same as recv()&lt;br /&gt;
&amp;nbsp; from -&amp;gt; is a pointer to struct sockaddr&lt;br /&gt;
&amp;nbsp; fromlen -&amp;gt; is a pointer to a local int that should be initialised&lt;br /&gt;
&amp;nbsp;     to sizeof(struct sockaddr)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;recvfrom() returns the number of bytes received and it&#39;ll return -1 on error.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &lt;strong&gt;close()&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;close(fd);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;close() is used to close the connection on your socket descriptor. If you call close(),&lt;br /&gt;
&amp;nbsp;it won&#39;t be no more writes or reads and if someone tries to read/write will receive an&lt;br /&gt;
&amp;nbsp;error.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;shutdown()&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;int shutdown(int fd, int how);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Let&#39;s see the arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; fd -&amp;gt; is the socket file descriptor you want to shutdown&lt;br /&gt;
&amp;nbsp; how -&amp;gt; you put one of those numbers:&lt;br /&gt;
&amp;nbsp;  &lt;br /&gt;
&amp;nbsp;    0 -&amp;gt; receives disallowed&lt;br /&gt;
&amp;nbsp;    1 -&amp;gt; sends disallowed&lt;br /&gt;
&amp;nbsp;    2 -&amp;gt; sends and receives disallowed&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;When how is set to 2, it&#39;s the same thing as close().&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;shutdown() returns 0 on success and -1 on error.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;strong&gt;gethostname()&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;int gethostname(char *hostname, size_t size);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Let&#39;s see the arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; hostname  -&amp;gt; is a pointer to an array that contains hostname&lt;br /&gt;
&amp;nbsp; size    -&amp;gt; length of the hostname array (in bytes)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;gethostname() is used to get the name of the local machine.&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://letuscodeinc.blogspot.com/feeds/3115817364455721268/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://letuscodeinc.blogspot.com/2011/05/important-functions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9166134204259279359/posts/default/3115817364455721268'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9166134204259279359/posts/default/3115817364455721268'/><link rel='alternate' type='text/html' href='http://letuscodeinc.blogspot.com/2011/05/important-functions.html' title='IMPORTANT FUNCTIONS'/><author><name>Ghost Henry</name><uri>http://www.blogger.com/profile/08996728742859917234</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9166134204259279359.post-7940766184533993084</id><published>2011-05-15T04:55:00.000-07:00</published><updated>2011-05-15T04:55:34.620-07:00</updated><title type='text'>Functions Related to IP Adress</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;In C, there are some functions that will help you manipulating IP addresses.&lt;br /&gt;
&lt;br /&gt;
inet_addr() converts an IP address into an unsigned long.&lt;br /&gt;
inet_ntoa() converts string IP addresses to long.&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://letuscodeinc.blogspot.com/feeds/7940766184533993084/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://letuscodeinc.blogspot.com/2011/05/functions-related-to-ip-adress.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9166134204259279359/posts/default/7940766184533993084'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9166134204259279359/posts/default/7940766184533993084'/><link rel='alternate' type='text/html' href='http://letuscodeinc.blogspot.com/2011/05/functions-related-to-ip-adress.html' title='Functions Related to IP Adress'/><author><name>Ghost Henry</name><uri>http://www.blogger.com/profile/08996728742859917234</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9166134204259279359.post-818894479423280012</id><published>2011-05-15T04:00:00.000-07:00</published><updated>2011-05-15T04:00:45.533-07:00</updated><title type='text'>Sockets Conversion Functions</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;There are two types of byte ordering: most significant byte and least significant byte.&lt;br /&gt;
This former is called &quot;Network Byte Order&quot; and some machines store their numbers internally&lt;br /&gt;
in Network Byte Order.&lt;br /&gt;
&lt;br /&gt;
There are two types you can convert: short and long.&lt;br /&gt;
Imagine you want to convert a long from Host Byte Order to Network Byte Order. &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;The following functions are used to convert :&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;htons() -&amp;gt; &quot;Host to Network Short&quot;&lt;br /&gt;
&amp;nbsp;htonl() -&amp;gt; &quot;Host to Network Long&quot;&lt;br /&gt;
&amp;nbsp;ntohs() -&amp;gt; &quot;Network to Host Short&quot;&lt;br /&gt;
&amp;nbsp;ntohl() -&amp;gt; &quot;Network to Host Long&quot;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://letuscodeinc.blogspot.com/feeds/818894479423280012/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://letuscodeinc.blogspot.com/2011/05/sockets-conversion-functions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9166134204259279359/posts/default/818894479423280012'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9166134204259279359/posts/default/818894479423280012'/><link rel='alternate' type='text/html' href='http://letuscodeinc.blogspot.com/2011/05/sockets-conversion-functions.html' title='Sockets Conversion Functions'/><author><name>Ghost Henry</name><uri>http://www.blogger.com/profile/08996728742859917234</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9166134204259279359.post-3118199750295604800</id><published>2011-05-14T12:28:00.000-07:00</published><updated>2011-05-15T03:03:22.593-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="socket programming c/c++ structures struct network unix"/><title type='text'>Socket Programming in C</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div align=&quot;center&quot;&gt;&lt;b&gt;What are Sockets?&lt;/b&gt;&lt;/div&gt;&amp;nbsp;Sockets provide a standard connection protocol which enables the communication of data over a network.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://www.tutorialspoint.com/images/sockets.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://www.tutorialspoint.com/images/sockets.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;Sockets supports both connection oriented (&lt;b&gt;T&lt;/b&gt;ransmission &lt;b&gt;C&lt;/b&gt;ontrol &lt;b&gt;P&lt;/b&gt;rotocol) and connectionless (&lt;b&gt;U&lt;/b&gt;ser&lt;b&gt; D&lt;/b&gt;atagram&lt;b&gt; P&lt;/b&gt;rotocol)&lt;br /&gt;
&amp;nbsp;Sockets can be easily configured to act like a client (The one which initiates the connection), or can act as a server (The one which accepts the connection).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;The Socket Structures:&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;The first structure is struct sockaddr that holds socket information.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;DejaVu Sans [unknown]&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;struct sockaddr&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;DejaVu Sans [unknown]&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;DejaVu Sans [unknown]&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; unsigned short  &amp;nbsp; sa_family;    &amp;nbsp; &amp;nbsp; &amp;nbsp;/* address family */&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;DejaVu Sans [unknown]&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; char &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;         sa_data[14];  &amp;nbsp;/* 14 bytes of protocol address */&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;DejaVu Sans [unknown]&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; };&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; class=&quot;src&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;Attribute&lt;/th&gt;&lt;th&gt;Values&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;sa_family&lt;/td&gt;&lt;td&gt;AF_INET&lt;br /&gt;
AF_UNIX&lt;br /&gt;
AF_NS&lt;br /&gt;
AF_IMPLINK&lt;/td&gt;&lt;td&gt;This represents an address family. In most of the Internet based applications we use AF_INET.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;sa_data&lt;/td&gt;&lt;td&gt;Protocol Specific Address&lt;/td&gt;&lt;td&gt;The content of the 14 bytes of protocol specific address are interpreted according to the type of address. For the Internet family we will use port number IP address which is represented by &lt;i&gt;sockaddr_in&lt;/i&gt; structure defined below.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
But, there&#39;s another structure (struct sockaddr_in) that help you to reference to the socket&#39;s elements.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;DejaVu Sans [unknown]&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;struct sockaddr_in&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;DejaVu Sans [unknown]&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;{&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;DejaVu Sans [unknown]&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;short int&lt;span style=&quot;font-family: &amp;quot;DejaVu Sans [unknown]&amp;quot;, sans-serif;&quot;&gt;  &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;sin_family;  /* Address family */&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;DejaVu Sans [unknown]&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;unsigned short int   &amp;nbsp; &amp;nbsp; sin_port;   /* Port */&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;DejaVu Sans [unknown]&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;struct in_addr      &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;sin_addr;   /* Internet Address */&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;DejaVu Sans [unknown]&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;unsigned char      &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sin_zero[8]; /* Same size as struct sockaddr */&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;DejaVu Sans [unknown]&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;};&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; class=&quot;src&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;Attribute&lt;/th&gt;&lt;th&gt;Values&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;sa_family&lt;/td&gt;&lt;td&gt;AF_INET&lt;br /&gt;
AF_UNIX&lt;br /&gt;
AF_NS&lt;br /&gt;
AF_IMPLINK&lt;/td&gt;&lt;td&gt;This represents an address family. In most of the Internet based applications we use AF_INET.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;sin_port&lt;/td&gt;&lt;td&gt;Service Port&lt;/td&gt;&lt;td&gt;A 16 bit port number in Network Byte Order.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;sin_addr&lt;/td&gt;&lt;td&gt;IP Address&lt;/td&gt;&lt;td&gt;A 32 bit IP address in Network Byte Order. &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;sin_zero&lt;/td&gt;&lt;td&gt;Not Used&lt;/td&gt;&lt;td&gt;You just set this value to NULL as this is not being used.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
struct in_addr&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;unsigned long &amp;nbsp; &amp;nbsp;s_addr;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; class=&quot;src&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;Attribute&lt;/th&gt;&lt;th&gt;Values&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;s_addr&lt;/td&gt;&lt;td&gt;service port&lt;/td&gt;&lt;td&gt;A 32 bit IP address in Network Byte Order. &lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
There is one more important structure. This structure is used to keep information related to host.&lt;br /&gt;
&lt;br /&gt;
struct hostent&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;char * &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;h_name;                 /* Official name of host.  */&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;char ** &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; h_aliases;             /* Alias list.  */&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;int &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;h_addrtype;               /* Host address type.  */&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;int &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;h_length;                 /* Length of address.  */&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;char ** &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; h_addr_list;           /* List of addresses from name server.  */&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;#define h_addr  &amp;nbsp; &amp;nbsp; &amp;nbsp;h_addr_list[0]  /* Address, for backward compatibility.  */&lt;br /&gt;
&amp;nbsp;};&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; class=&quot;src&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;Attribute&lt;/th&gt;&lt;th&gt;Values&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;h_name&lt;/td&gt;&lt;td&gt;ti.com etc&lt;/td&gt;&lt;td&gt;This is official name of the host. For example tutorialspoint.com, google.com etc.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;h_aliases&lt;/td&gt;&lt;td&gt;TI&lt;/td&gt;&lt;td&gt;This will hold a list of host name aliases.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;h_addrtype&lt;/td&gt;&lt;td&gt;AF_INET&lt;/td&gt;&lt;td&gt;This contains the address family and in case of Internet based application it will always be AF_INET&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;h_length&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;This will hold the length of IP address which is 4 for Internet Address.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;h_addr_list&lt;/td&gt;&lt;td&gt;in_addr&lt;/td&gt;&lt;td&gt;For the Internet addresses the array of pointers h_addr_list[0], h_addr_list[1] and so on are points to structure in_addr.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
Following structure is used to keep information related to service and associated ports.&lt;br /&gt;
&lt;br /&gt;
struct servent&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;char  *s_name;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;char  **s_aliases;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;int   s_port; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;char  *s_proto;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; class=&quot;src&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;Attribute&lt;/th&gt;&lt;th&gt;Values&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;s_name&lt;/td&gt;&lt;td&gt;http&lt;/td&gt;&lt;td&gt;This is official name of the service. For example SMTP, FTP POP3 etc.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;s_aliases&lt;/td&gt;&lt;td&gt;ALIAS&lt;/td&gt;&lt;td&gt;This will hold list of service aliases. Most of the time this will be set to NULL.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;s_port&lt;/td&gt;&lt;td&gt;80&lt;/td&gt;&lt;td&gt;This will have associated port number. For example for HTTP this will be 80.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;s_proto&lt;/td&gt;&lt;td&gt;TCP &lt;br /&gt;
UDP&lt;/td&gt;&lt;td&gt;This will be set to the protocol used. Internet services are provided using either TCP or UDP.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://letuscodeinc.blogspot.com/feeds/3118199750295604800/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://letuscodeinc.blogspot.com/2011/05/socket-programming-in-c.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9166134204259279359/posts/default/3118199750295604800'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9166134204259279359/posts/default/3118199750295604800'/><link rel='alternate' type='text/html' href='http://letuscodeinc.blogspot.com/2011/05/socket-programming-in-c.html' title='Socket Programming in C'/><author><name>Ghost Henry</name><uri>http://www.blogger.com/profile/08996728742859917234</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>