AF_UNIX versus AF_INET


 
Thread Tools Search this Thread
Special Forums Cybersecurity AF_UNIX versus AF_INET
# 1  
Old 10-08-2002
AF_UNIX versus AF_INET

I'm using AF_INET in sockets for inter process communication on the same machine. Is AF_UNIX better for IPC on the same machine than AF_INET in terms of performance? If so, how much better? I would like to know if there is sample code available to test this. I'm running the program on Solaris.

Thanks,
-Vijay
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. SCO

Printing via hpnpf versus lp

Hi, We have a Unix 3.2v5.0.5. I installed a printer via scoadmin, HP network printer manager with network peripheral name an ip-adress. This is the configuration file : Code: root@sco1 # cat configurationBanner: on:AlwaysContent types: simpleDevice: /dev/null Interface:... (2 Replies)
Discussion started by: haezeban
2 Replies

2. Solaris

Solaris versus Centos

hi guys In a few days I will be working in a new Job my new chief told I will be using Solaris and since I know Centos-Red Hat-Fedora I would like to know if Solaris is that different from Centos and my other linux Flavors... by the way any good solaris manual thanks a lot (1 Reply)
Discussion started by: karlochacon
1 Replies

3. Shell Programming and Scripting

Bourne sh versus bash

Hi All, I know difference between shell(s) we are using, ie. sh, bash etc. But while writing shell script, is there any difference which shell I am using. and if yes, what are they? (4 Replies)
Discussion started by: Deei
4 Replies

4. Shell Programming and Scripting

Awk Versus Cut

Hello ALL, I am looking for a comparison in 2 commands using awk and cut that would replicate the following command below. This is completely for speed reasons checking apache logs for unique IPs. Contender #1 awk '{!a++}END{for(i in a) if ( a >10 ) print a,i }' access_log I need a... (6 Replies)
Discussion started by: jaysunn
6 Replies

5. Programming

C & TCP question: AF_INET vs AF_UNIX

Greetings! I am attempting to write a *basic* network client in C. I have manage to create a socket but I have doubts as far as using AF_INET vs AF_UNIX. At the present time, my client runs with AF_INET. Is AF_UNIX faster across hosts using the same OS flavor (Red Hat)? What is the difference... (1 Reply)
Discussion started by: Alan Christen
1 Replies

6. IP Networking

What does 'AF' of AF_INET stand for ?

as title. and how is it different from PF_INET ? also, any one knows sin_family , sin_port , sin_addr ..etc ? why are they called 'sin' ? finally, htons() host to network short , htonl() host to network long , ntohs() network to host short , ntohl() network to host long. why would... (6 Replies)
Discussion started by: trapeze
6 Replies

7. Shell Programming and Scripting

.chsrc Versus .login

All, I am trying to understand the difference between .login & .cshrc. My understanding here is, there is not much difference between .cshrc and .login. Both the files accomplish the same purpose. But the calling order is different. The .login file called only when you login after calling .cshrc... (1 Reply)
Discussion started by: govindts
1 Replies

8. UNIX for Advanced & Expert Users

cpio versus cp

I am copying a file system to another one. someone suggest me use find . -print |cpio -pdmv but I think cp -r should do the same thing. Am I right? In addition, by using " find . ", I got all the file names,, why do I have to use the -print option? Thanks a lot! (1 Reply)
Discussion started by: fredao
1 Replies

9. Shell Programming and Scripting

<LF> versus <CR>/<LF>

Hello, Can someone explain how to distinguish a LF character and a CR/LF character in a text file from a shell script. Thanks (1 Reply)
Discussion started by: jerardfjay
1 Replies

10. UNIX for Dummies Questions & Answers

CTRL+H versus ^? versus BACKSPACE

Hi Gurus! I recently got my shell account (HP UX v11) created by our sysadmin and am having problem deleting with the backspace key. After doing some reading, I believe I need to enter a custom "STTY..." statement in my profile. Can someone please help me with the correct "STTY" sequence... (3 Replies)
Discussion started by: alan
3 Replies
Login or Register to Ask a Question
SOCKET_CREATE_PAIR(3)							 1						     SOCKET_CREATE_PAIR(3)

socket_create_pair - Creates a pair of indistinguishable sockets and stores them in an array

SYNOPSIS
bool socket_create_pair (int $domain, int $type, int $protocol, array &$fd) DESCRIPTION
socket_create_pair(3) creates two connected and indistinguishable sockets, and stores them in $fd. This function is commonly used in IPC (InterProcess Communication). PARAMETERS
o $domain - The $domain parameter specifies the protocol family to be used by the socket. See socket_create(3) for the full list. o $type - The $type parameter selects the type of communication to be used by the socket. See socket_create(3) for the full list. o $protocol - The $protocol parameter sets the specific protocol within the specified $domain to be used when communicating on the returned socket. The proper value can be retrieved by name by using getprotobyname(3). If the desired protocol is TCP, or UDP the corre- sponding constants SOL_TCP, and SOL_UDP can also be used. See socket_create(3) for the full list of supported protocols. o $fd - Reference to an array in which the two socket resources will be inserted. RETURN VALUES
Returns TRUE on success or FALSE on failure. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.0 | | | | | | | This function is now re-enabled on Windows plat- | | | forms. | | | | | 4.3.0 | | | | | | | This function was due to a bug made unavailable | | | on Windows platforms. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 socket_create_pair(3) example <?php $sockets = array(); /* On Windows we need to use AF_INET */ $domain = (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' ? AF_INET : AF_UNIX); /* Setup socket pair */ if (socket_create_pair($domain, SOCK_STREAM, 0, $sockets) === false) { echo "socket_create_pair failed. Reason: ".socket_strerror(socket_last_error()); } /* Send and Recieve Data */ if (socket_write($sockets[0], "ABCdef123 ", strlen("ABCdef123 ")) === false) { echo "socket_write() failed. Reason: ".socket_strerror(socket_last_error($sockets[0])); } if (($data = socket_read($sockets[1], strlen("ABCdef123 "), PHP_BINARY_READ)) === false) { echo "socket_read() failed. Reason: ".socket_strerror(socket_last_error($sockets[1])); } var_dump($data); /* Close sockets */ socket_close($sockets[0]); socket_close($sockets[1]); ?> Example #2 socket_create_pair(3) IPC example <?php $ary = array(); $strone = 'Message From Parent.'; $strtwo = 'Message From Child.'; if (socket_create_pair(AF_UNIX, SOCK_STREAM, 0, $ary) === false) { echo "socket_create_pair() failed. Reason: ".socket_strerror(socket_last_error()); } $pid = pcntl_fork(); if ($pid == -1) { echo 'Could not fork Process.'; } elseif ($pid) { /*parent*/ socket_close($ary[0]); if (socket_write($ary[1], $strone, strlen($strone)) === false) { echo "socket_write() failed. Reason: ".socket_strerror(socket_last_error($ary[1])); } if (socket_read($ary[1], strlen($strtwo), PHP_BINARY_READ) == $strtwo) { echo "Recieved $strtwo "; } socket_close($ary[1]); } else { /*child*/ socket_close($ary[1]); if (socket_write($ary[0], $strtwo, strlen($strtwo)) === false) { echo "socket_write() failed. Reason: ".socket_strerror(socket_last_error($ary[0])); } if (socket_read($ary[0], strlen($strone), PHP_BINARY_READ) == $strone) { echo "Recieved $strone "; } socket_close($ary[0]); } ?> SEE ALSO
socket_create(3), socket_create_listen(3), socket_bind(3), socket_listen(3), socket_last_error(3), socket_strerror(3). PHP Documentation Group SOCKET_CREATE_PAIR(3)