1820475 Members
2860 Online
109624 Solutions
New Discussion юеВ

sockets and threads

 
SOLVED
Go to solution
Shivkumar
Super Advisor

sockets and threads

Dear Sirs,

Is there any relationship between operating system sockets and appplications threads ( with regard to threads in web logic or web server)?

Thanks,
Shiv
3 REPLIES 3
Indira Aramandla
Honored Contributor
Solution

Re: sockets and threads

Hi Shiv,

A socket is an endpoint for communication between two machines. A method of communication between two processes. A socket is an identifier that the application uses to uniquely identify an end point of communications. The user associates a protocol address with the socket by associating a socket address with the socket.

The socket() system call creates an endpoint for communication and returns a descriptor. The socket descriptor returned is used in all subsequent socket-related system calls.

A thread is a processor activity in a process or A thread is a thread of execution in a program.
The same process can have multiple threads. Those threads share the process address space and can therefore share data. Threads are similar to processes, in that both represent a single sequence of instructions executed in parallel with other sequences, either by time slicing or multiprocessing. Threads are a way for a program to split itself into two or more simultaneously running tasks. (The name "thread" is by analogy with the way that a number of threads are interwoven to

Every thread has a priority. Threads with higher priority are executed in preference to threads with lower priority. Each thread may or may not also be marked as a daemon. When code running in some thread creates a new Thread object, the new thread has its priority initially set equal to the priority of the creating thread, and is a daemon thread if and only if the creating thread is a daemon.


IA
Never give up, Keep Trying
Ralph Grothe
Honored Contributor

Re: sockets and threads

It's all perfectly answered by Indira and can hardly be put better.
However, I dare a minute "correction".
Sockets aren't necessarily restricted to communication between processes on two separate machines (albeit this probably being the majority, in the case of INET sockets).
Sockets may also serve communication endpoints for processes on the same host,
as is the case with UNIX sockets.
For instance you can find such sockets that being accessed today on your system as special files marked with a leading "s" in the long listing.

# find /var -xdev -type s -atime -1 -exec ll {} \;
srwxrwxrwx 1 root root 0 Jul 27 08:23 /var/opt/dce/rpc/local/02279/c-0/9456
srwxrwxrwx 1 root root 0 Jul 27 08:04 /var/spool/sockets/pwgr/client1409
srwxrwxrwx 1 root users 0 Jul 27 08:04 /var/spool/sockets/pwgr/client1414
srwxrwxrwx 1 root users 0 Jul 27 07:58 /var/spool/sockets/pwgr/client273
srwxrwxrwx 1 root users 0 Jul 27 08:04 /var/spool/sockets/pwgr/client1434
srwxrwxrwx 1 root sys 0 Jul 27 08:25 /var/spool/sockets/pwgr/client15130
srwxrwxrwx 1 root root 0 Jul 27 08:22 /var/spool/sockets/pwgr/client23998
Madness, thy name is system administration
Mahesh Kumar Malik
Honored Contributor

Re: sockets and threads

Hi Shiv

1. Sockets are just like "worm holes" in science fiction. When things go into one end, they (should) come out of the other. Different kinds of sockets have different properties. Sockets are either connection-oriented or connectionless. Connection-oriented sockets allow for data to flow back and forth as needed, while connectionless sockets (also known as datagram sockets) allow only one message at a time to be transmitted, without an open connection. There are also different socket families. The two most common are AF_INET for internet connections, and AF_UNIX for unix IPC (interprocess communication).


2. Thread---This defines interfaces and functionality to support multiple flows of control, called threads, within a process.
Threads define system interfaces to support the source portability of applications. The key elements defining the scope are:


a. defining a sufficient set of functionality to support multiple threads of control within a process

b. defining a sufficient set of functionality to support the realtime application domain

c. defining sufficient performance constraints and performance related functions to allow a realtime application to achieve deterministic response from the system.

d. The definition of realtime used in defining the scope of this specification is:

The ability of the system to provide a required level of service
in a bounded response time.

Regards
Mahesh