Socket Programming Interview Questions and answers

HOME C C++ STL MFC Win32 SDK ATL COM DCOM WinCE Sockets
Data Structures Windows SQL Multi Threading
 


Name
bind - bind a name to a socket
Synopsis
#include <sys/types.h>
#include <sys/socket.h>
int bind(int sockfd, const struct sockaddr *my_addr", socklen_t " addrlen );

Name
accept - accept a connection on a socket
Synopsis
#include <sys/types.h>
#include <sys/socket.h>
int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);


Name
connect - initiate a connection on a socket
Synopsis
#include <sys/types.h>
#include <sys/socket.h>
int connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen);

Name
listen - listen for connections on a socket
Synopsis
#include <sys/socket.h>
int listen(int sockfd, int backlog);

Name
recv, recvfrom, recvmsg - receive a message from a socket
Synopsis
#include <sys/types.h>
#include <sys/socket.h>
ssize_t recv(int s, void *buf, size_t len, int flags);
ssize_t recvfrom(int s, void *buf, size_t len, int flags,
   struct sockaddr *from, socklen_t *fromlen);
ssize_t recvmsg(int s, struct msghdr *msg, int flags);

Name
send, sendto, sendmsg - send a message on a socket
Synopsis
#include <sys/types.h>
#include <sys/socket.h>
ssize_t send(int s, const void *buf, size_t len, int flags);
ssize_t sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen);
ssize_t sendmsg(int s, const struct msghdr *msg, int flags);