You Are Here:

Community: Wiki

This page was last modified on 25 September 2009, at 20:15.

Open C Sockets: socket method

From Forum Nokia Wiki

Reviewer Approved   

The socket method creates an endpoint for communication.

int socket (int domain, int type, int protocol);

The socket system call creates an endpoint for communication and returns a descriptor.

The domain argument specifies a communications domain within which communication will take place; this selects the protocol family which should be used. These families are defined in the include file sys/socket.h. The protocol argument specifies a particular protocol to be used with the socket.

Following code snippet shows the usage of socket function:

#include <sys/socket.h>
#include <unistd.h>
#include <stdio.h>
#inlcude <netinet/in.h>
void SocketExample()
{
int sock_fd;
sock_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
close(sock_fd);
}


Wiki Links

Open C Sockets Overview

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
User Rating: qfnZuserE5FratingQNx1E2E0000X