Re: client/server communication using CFSocket (no one listening to port 2222)
Re: client/server communication using CFSocket (no one listening to port 2222)
- Subject: Re: client/server communication using CFSocket (no one listening to port 2222)
- From: Josh Graessley <email@hidden>
- Date: Fri, 20 Jan 2006 10:53:24 -0800
If you're looking for a list of which ports are in use, you're much
better off using netstat. netstat looks at the list of protocol
control blocks for TCP and UDP. This will include sockets that have
been closed but are sitting in the close wait state. This will also
include all sockets created in the kernel that don't have an
associated file descriptor. lsof will just list sockets that have a
file descriptor associated with them. It is possible that if you run
your app once and it crashes, you may not be able to bind again
immediately unless you use the SO_REUSEADDR socket option.
-josh
On Jan 19, 2006, at 11:39 PM, Rola Alame wrote:
From: Frederick Cheung <email@hidden>
To: Rola Alame <email@hidden>
CC: email@hidden
Subject: Re: client/server communication using CFSocket
Date: Thu, 19 Jan 2006 12:54:14 +0000
On 1/19/06, Rola Alame <email@hidden> wrote:
> Hello.
>
> I'm writing two applications: one is a client and the other is a
server for
> them to communicate over the network using TCP/IP. i'm using
high level
> CFSocket function. The client is working fine. however, at the
server, i'm
> successfully creating the socket (with CFSocketCreate), but when
i use
> "CFSocketSetAddress" to bind a port to that socket, it's returning
> kCFSocketError. and i can't figure out why. Here's the code for
the server:
>
> when irun this code i always get the error message printed on
the terminal.
> Can anyone tell me what the problem could be and how to solve it?
>
Just checking, 192.168.1.11 is an address of one of your machine's
interfaces (unless you have a particular need often it's best to bind
to INADDR), and there's no one else listening on port 2222 (use lsof
to check) ?
Fred
yes, this is the address of one of my machine interfaces. (i tried
with inaddr_any but it gave the same problem). also i'm sure that
port 2222 is free for two reasons:
1- i used lsof to be sure, and
2- i ran another server program that i wrote using BSD socket
functions (socket, accept, listen, bind...) and the CFSocket client
and BSD socket server were able to communicate together.
What do you figure?
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden