are socket newlib socket functions alias to sceNetInet*?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Heimdall
Posts: 245
Joined: Thu Nov 10, 2005 1:29 am
Location: Netherlands
Contact:

are socket newlib socket functions alias to sceNetInet*?

Post by Heimdall »

newlib contains a bsd socket implementation but sony created their own API sceNetInet*, what are the differences between then?

can I code my app using the "standard" bsd socket functions or should I replace all the newlib function names with the sony API something like:

Code: Select all

#define accept sceNetInetAccept
#define bind sceNetInetBind
#define close sceNetInetClose
#define connect sceNetInetConnect
#define getpeername sceNetInetGetpeername
#define getsockname sceNetInetGetsockname
#define getsockopt sceNetInetGetsockopt
#define listen sceNetInetListen
#define recv sceNetInetRecv
#define recvfrom sceNetInetRecvfrom
#define recvmsg sceNetInetRecvmsg
#define send sceNetInetSend
#define sendto sceNetInetSendto
#define sendmsg sceNetInetSendmsg
#define setsockopt sceNetInetSetsockopt
#define shutdown sceNetInetShutdown
#define socket sceNetInetSocket
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

The newlib patch implements exactly this, whether you use the newlib functions or sceNetInet*, the sceNetInet* function will be called.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Not quite, the newlib BSD socket library does eventually call down to the sce ones but you cannot mix sockets created on the BSD side with the native side cause it does some mapping to allow you to use them with things like close()/read()/write() etc. You might as well just use the BSD socket layer in the end though for portability.
Heimdall
Posts: 245
Joined: Thu Nov 10, 2005 1:29 am
Location: Netherlands
Contact:

Post by Heimdall »

I guess that is my current problem, i've mixed BSD and SCE sockets and when i invoke the connect function from BSD it always returns -1.

And another question, will select() work with SCE socket fd's? or does it require BSD ones?

(i guess this is a dumb question but you said they could conflict on read/write/close).
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Yah select is the same, it needs sockets created with the BSD interface, it also emulates a real select in that you can also multiplex that select with file descriptors (from open()) which the sceInet one can't do.

You need to choose one or the other I am afraid :/
Post Reply