LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-08-2008, 01:50 AM   #1
sweetytweety
LQ Newbie
 
Registered: May 2008
Posts: 17

Rep: Reputation: 0
unix domain socket :how to choose the path(sun_path)


hi
im new to linux programming. i have done the server to client and client to server program.
i have one doubt in that. In struct sockaddr_un.sun_path(how to give the path name).i ve created one directory called "tmpecho_socket" and the both(server to client and client to server ) are in the same directroy (tmpecho_socket)so i ve given the path name "/tmpecho_socket/". i dont know what i did is correct. but while running my server program im getting the error message "bind: Socket operation on non-socket". & in client "connect: No such file or directory". how can i solve my problem. Can someone give me the solution.Thankyou
 
Old 05-08-2008, 03:17 AM   #2
datopdog
Member
 
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806

Rep: Reputation: 41
That is incorrect it seems you are pointing to a directory instead of pointing to a socket file.
 
Old 05-08-2008, 03:28 AM   #3
sweetytweety
LQ Newbie
 
Registered: May 2008
Posts: 17

Original Poster
Rep: Reputation: 0
Thank you very much for your reply.How can i point to socket file?
My file name for client: "echoc.c" & server: "echos.c" both are in the same directory . can you explain me how to create the file(file name) and give the same to sun_path?
 
Old 05-08-2008, 03:40 AM   #4
datopdog
Member
 
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806

Rep: Reputation: 41
Take a look at this http://beej.us/guide/bgnet/
 
Old 05-08-2008, 04:27 AM   #5
sweetytweety
LQ Newbie
 
Registered: May 2008
Posts: 17

Original Poster
Rep: Reputation: 0
i ve gone through it. but it explains only about internet socket nothing given about unix domain socket
 
Old 05-08-2008, 04:46 AM   #6
datopdog
Member
 
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806

Rep: Reputation: 41
The file name can be any thing say /tmp/mytest.sock

You can then place that in a char variable say localSocket then

Code:
sockun.sun_family = AF_UNIX;
strncpy(sockun.sun_path, localSocket,sizeof(sockun.sun_path));
 
Old 05-08-2008, 05:00 AM   #7
sweetytweety
LQ Newbie
 
Registered: May 2008
Posts: 17

Original Poster
Rep: Reputation: 0
Thanks for your speedy response. now i ve to create one file in my directory then i ve to paste my both(client to server &server to client program). then i ve to give that file name to sun_path. is this right.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP UNIX Domain Socket Programming anamericanjoe Programming 2 12-08-2006 03:10 AM
script to change unix path to windows path in all files csross Programming 8 04-29-2006 02:05 PM
connection between java socket and unix socket sathishkumar Programming 1 01-10-2006 04:21 PM
unix domain socket: how to know if i use recvmsg or read Thinking Programming 3 09-23-2005 02:51 AM
Unable to connect to UNIX socket /tmp/.esd/socket error while using grip dr_zayus69 Linux - Software 4 08-23-2005 08:28 PM


All times are GMT -5. The time now is 04:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration