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); }
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| NoClassDefFoundError - Defining a class? | dreamix | Mobile Java General | 1 | 2005-02-20 16:51 |
| Socket connection CRASH with KERN-EXEC 3 | agsapt | Symbian Networking & Messaging | 1 | 2002-08-27 03:43 |
| 可以用 c api 寫 series60 上面的 socket client 嗎 | barry0312 | Symbian | 7 | 2004-02-02 15:56 |
| POST with socket | giudicea | General Symbian C++ | 1 | 2004-04-05 12:07 |
| Socket 6610 | sa58154 | Mobile Java Networking & Messaging & Security | 5 | 2003-11-20 21:13 |