LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Problem with connect() (https://www.linuxquestions.org/questions/linux-newbie-8/problem-with-connect-650762/)

x_gaurav 06-21-2008 02:44 PM

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.

pinniped 06-22-2008 08:23 AM

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.

chrism01 06-22-2008 06:24 PM

Maybe you could show us the code?

x_gaurav 06-24-2008 12:42 AM

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.


All times are GMT -5. The time now is 01:32 PM.