Category: 

What Is Socket C?

Article Details
  • Written By: Eugene P.
  • Edited By: Angela B.
  • Last Modified Date: 05 September 2016
  • Copyright Protected:
    2003-2016
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog
The U.S. Coast Guard led the evacuation of more than 500,000 people from Lower Manhattan on 11 September 2001.  more...

September 27 ,  1940 :  The World War II Axis powers formed with the signing of the Tripartite Pact.  more...

"Socket C" is a term that sometimes is used to refer to the process of writing socket code in the C programming language and sometimes is used to refer to the actual library file that holds the implementation for some socket functions. The actual socket C library file contains implementations for different functions and macros that provide the basic socket functionality supplied by the language libraries, although the socket C file is operating-system-dependent and might not be implemented on some systems. Writing socket C code involves creating an interface with a standard input and output protocol, known as a socket, and using it to send or receive information, usually over a network or through a piece of hardware. The C programming language is intended to be portable, but socket programming relies on some low-level system specific functions, so it sometimes can be difficult to write programs in C that use sockets but also maintain cross-system portability.

Ad

There are three basic types of sockets that socket C supports. The first is known as a datagram, the second is a stream, and the third is raw access. A datagram is a type of socket that sends information in small bundles known as packets. Each packet is sent from a source with information on the destination socket it is seeking across a network. While a datagram can be an efficient method of communicating through sockets and often is used to send email, it also is lossy, because no packet that is sent is guaranteed to arrive at the destination socket.

A stream socket makes a connection to another socket and information is passed directly between the sockets. When used in socket C programming, this type of socket ensures that all data that are sent are received on the other side. One complication, however, is that the socket sometimes can use blocking, meaning the socket will stop execution of a process until information is received or until the socket is closed, although using threads or forked processes can resolve this issue in most instances. Raw socket access is provided as a means of actually interfacing on a nearly hardware level with whatever device is hosting the socket.

Sockets commonly are used in various forms for Internet communications. The hardware and drivers that allow networking to occur vary greatly by operating system, so it can be difficult to locate a socket C library file that supports all possible combinations. For this reason, the socket C file itself, as well as the socket header file, often contains a long list of conditional compilation directives so it will compile differently on various systems.

Ad

You might also Like

Recommended

Discuss this Article

Post your comments

Post Anonymously

Login

username
password
forgot password?

Register

username
password
confirm
email