LinuxQuestions.org
Visit Jeremy's Blog.
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 06-21-2008, 03:44 PM   #1
x_gaurav
LQ Newbie
 
Registered: Apr 2008
Posts: 8

Rep: Reputation: 0
Problem with connect()


Hi

I am trying to write a simple client server socket program in C using Internet Domain Sockets.
The connect call is failing with the error message- Bad File Descriptor.
The server program is running fine(I think). Can someone help me out with this.
I am logged in as root when executing the programs.

Last edited by x_gaurav; 06-21-2008 at 04:02 PM.
 
Old 06-22-2008, 09:23 AM   #2
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
It sounds like you didn't check the return value of the socket() call - or that you never even called socket().

To connect:
1. open a socket: socket()
2. fill in an address struct with the destination address (IP and port)
3. make the connection: connect()

The socket has to be a stream type; if it is a 'datagram' then connect will fail since connect() only works with streams - which makes sense because a datagram like UDP is a "connectionless" protocol.
 
Old 06-22-2008, 07:24 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
Maybe you could show us the code?
 
Old 06-24-2008, 01:42 AM   #4
x_gaurav
LQ Newbie
 
Registered: Apr 2008
Posts: 8

Original Poster
Rep: Reputation: 0
hey
Thanks for the help. Unfortunately i deleted the file in frustration, rewrote it and somehow it started working. Now i can't remember what was wrong with it.
 
  


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
problem in connect sofian44 Red Hat 1 11-13-2007 04:11 PM
ftp connect problem. bruse Linux - Networking 7 01-20-2006 07:31 AM
Problem to connect with AccessPoint jenser Linux - Wireless Networking 0 02-15-2005 04:42 PM
Problem withInternet, DHCP, connect with eth0 down work, connect with eth0 up not zowey Linux - Networking 1 03-12-2004 11:05 AM
DBI->connect problem pigsy Programming 4 06-02-2003 03:41 PM


All times are GMT -5. The time now is 01:08 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