Community: Wiki

你在这里: You Are Here: Olet tässä: Vous êtes ici: Sie befinden sich hier: Tu sei qui: 現在のページ: Você está aqui: Вы здесь: Usted está aquí:
This page was last modified 12:52, 17 June 2008.

Open C Sockets: listen method

From Forum Nokia Wiki


The listen method listens for connections on a socket.

int listen (int s, int backlog);

The s argument is a socket and the backlog argument defines the maximum length the queue of pending connections may grow to. The real maximum queue length will be 1.5 times more than the value specified in the backlog argument.

Following is the usage of listen function:

#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
void listen_example()
{
   int sock_fd;
   int newsock_fd;
   struct sockaddr_in addr;
   struct sockaddr_in ss;
   struct sockaddr_in new_socket;
   unsigned int len;
   unsigned int addr_len;
   
   sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
       
   addr.sin_family = AF_INET;
   addr.sin_addr.s_addr = htonl(INADDR_ANY);
   addr.sin_port = htons(5000);
   bind(sock_fd,(struct sockaddr*)&addr,sizeof(addr));
   listen(sock_fd,1);
   close(sock_fd);
}


Wiki Links

Open C Sockets Overview

Related Discussions

Thread Thread Starter Forum Replies Last Post
CSecureSocket Recv(), send() not working? bnvaikos Symbian Networking & Messaging 0 2006-12-16 12:24
help regarding sockets jan_s15 Symbian Networking & Messaging 5 2006-02-14 08:34
Ipc vyom_garg Symbian Networking & Messaging 0 2003-05-13 13:37
Appl Not responding when I use Sockets mobileteam Symbian Networking & Messaging 10 2008-05-14 16:44
socket example pappago Symbian Tools & SDKs 1 2002-12-24 06:17

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditFurlTechnocratiMagnoliaTwitter  Share this page Share this page Invite a friend Invite a friend
E-mail Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us Regional websites: Chinese Japanese © 2008 Nokia 
RDF Facets: qfnZtypeQUqfnTypeZCommunityContentQ qfnZtypeQUqfnTypeZWebpageQ qfnZtypeQUqfnTypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX