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 23:40, 14 July 2008.

Open C Sockets: getsockname method

From Forum Nokia Wiki

  • getsockname - gets socket name
int getsockname (int s, struct sockaddr * restrict name, socklen_t * restrict namelen);

The getsockname system call returns the current name for the specified socket. The namelen argument should be initialized to indicate the amount of space pointed to by name. On return it contains the actual size of the name returned (in bytes).

Following is the usage of getsockname function:

#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
TInt GetSockName()
{
   int sock_fd;
   struct sockaddr_in addr,ss;
   unsigned int 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));
 
  len=sizeof(ss);
  getsockname(sock_fd,(struct sockaddr*)&ss,&len);
  close(sock_fd);
}

Wiki Links

Open C Sockets Overview

Related Discussions

Thread Thread Starter Forum Replies Last Post
Best way to transfer files over GPRS AndreaMobile Symbian Networking & Messaging 11 2007-04-02 17:28
Run Java code from PyS60? jibberia Python 5 2007-04-18 15:41
Create a services like application. aamitgupta General Symbian C++ 8 2008-09-03 16:11
Problem with c++ string lucafr General Symbian C++ 2 2008-09-25 23:20
Limitation of Series 60. Urgent!!! gregory12 General Symbian C++ 0 2005-07-24 01:24

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