Main Page | Report this Page
Computers Forum Index  »  Computer Languages (Objective-C)  »  CFSocketCreate and declarations...
Page 1 of 1    

CFSocketCreate and declarations...

Author Message
Adam Lang...
Posted: Sat Aug 08, 2009 4:13 am
Guest
I am just starting Objective-C, but have other programming experience
(predominantly Java and Visual Basic). I am trying to get socket
programming to work but am having some problems with type
declarations. I am guessing there are some header files I am not
properly importing?

For example I have this:

TCPServer = CFSocketCreate(kCFAllocatorDefault, PF_INET, SOCK_STREAM,
IPPROTO_TCP, kCFSocketAcceptCallBack, (CFSocketCallBack)
&AcceptCallback, &CTX);

And I am getting PF_INET, SOCK_STREAM, IPPROTO_TCP listed as
undeclared.

I imported this:
#import <Foundation/Foundation.h>
#import <CoreFoundation/CoreFoundation.h>

Seeing if I was just missing a header file, but to no avail. Nor can
I find any leads on why it is happening. Any ideas?
 
Stefan Arentz...
Posted: Sat Aug 08, 2009 6:55 pm
Guest
Adam Lang <raider.adam at (no spam) gmail.com> writes:

Quote:
I am just starting Objective-C, but have other programming experience
(predominantly Java and Visual Basic). I am trying to get socket
programming to work but am having some problems with type
declarations. I am guessing there are some header files I am not
properly importing?

For example I have this:

TCPServer = CFSocketCreate(kCFAllocatorDefault, PF_INET, SOCK_STREAM,
IPPROTO_TCP, kCFSocketAcceptCallBack, (CFSocketCallBack)
&AcceptCallback, &CTX);

And I am getting PF_INET, SOCK_STREAM, IPPROTO_TCP listed as
undeclared.

#include <sys/socket.h>
#include <netinet/in.h>

S.
 
hns at (no spam) computer.org...
Posted: Sat Aug 22, 2009 11:02 am
Guest
On 8 Aug., 06:13, Adam Lang <raider.a... at (no spam) gmail.com> wrote:
Quote:
I am just starting Objective-C, but have other programming experience
(predominantly Java and Visual Basic).  I am trying to get socket
programming to work but am having some problems with type
declarations.  I am guessing there are some header files I am not
properly importing?

For example I have this:

TCPServer = CFSocketCreate(kCFAllocatorDefault, PF_INET, SOCK_STREAM,
IPPROTO_TCP, kCFSocketAcceptCallBack, (CFSocketCallBack)
&AcceptCallback, &CTX);

And I am getting PF_INET, SOCK_STREAM, IPPROTO_TCP listed as
undeclared.

I imported this:
#import <Foundation/Foundation.h
#import <CoreFoundation/CoreFoundation.h

Seeing if I was just missing a header file, but to no avail.  Nor can
I find any leads on why it is happening.  Any ideas?

For completeness: CFSocketCreate() is plain C and not Objective-C and
is part of Apple's CoreFoundation framework. You can regard it as some
"internal" implementation library that you should not use (unless you
have a good reason to do so). Unfortunately you can already find a
horrible (and in 99% unnecessary) mixture of Obj-C and CF on the
Web...

If you want to stay within Objective-C, please use the classes
NSStream and friends which wrap most TCP/IP (incl. ssh access).

-- hns
 
 
Page 1 of 1    
All times are GMT
The time now is Sun Nov 29, 2009 8:44 am