Discuss the development of new homebrew software, tools and libraries.
Moderators: cheriff , TyRaNiD
Heimdall
Posts: 245 Joined: Thu Nov 10, 2005 1:29 am
Location: Netherlands
Contact:
Post
by Heimdall » Tue Jul 22, 2008 6:22 pm
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 » Tue Jul 22, 2008 9:34 pm
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 » Wed Jul 23, 2008 4:02 am
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 » Wed Jul 23, 2008 5:08 pm
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 » Thu Jul 24, 2008 4:07 am
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 :/