Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 361
  • Last Modified:

Sockets portability

I am writing a sockets class to be the communications backbone for a distributed application.  I'm getting conflicting information on the portability of winsock.  Some of my information says that it is fully portable, while other implies it is a windows-only thing.  I need to be able to port code from a win-nt development enviroment to run on a power-pc.  I'm accustomed to letting the JVM take care of all this stuff for me, so I'm kinda lost.  Thanks for your help.
0
Chris1078
Asked:
Chris1078
  • 3
  • 2
  • 2
  • +1
1 Solution
 
wkmatt42Commented:
Anything function that starts with WSA is not portable. Functions like socket(), accept(), bind(), connect(), etc. should be, though the header files you'll need to include will likely vary.

What OS is running on the power-pc?
0
 
Chris1078Author Commented:
Eventually, it will be running integrity OS.
0
 
jhanceCommented:
The WINSOCK sockets library is a pretty good approximation of the Berkeley sockets library more common to unix systems.  It is NOT, however, a 100% compatible library.  There are some features missing or slightly different between the two.  It is, however, possible to account for these in preprocessor directives and so on to be able to have a single source for a multi-platform sockets package.  Be aware, as mentioned above, that the WINSOCK ASYNC calls, those starting with WSA, have NO counterpart in a Berkeley sockets library.  Also be aware that blocking sockets are not usually a concern on unix since it's common to use fork() for such calls.  Since Windows has no fork() counterpart, this can be a significant design issue for you.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Chris1078Author Commented:
In regards to the fork comment above:
I've used fork, but isin't there a "create process" or some such command for windows?  I believe it dosen't create an exact copy like fork, but allows you to create a seperate thread of execution.  Anybody know about that?  I had been planning on using fork down the road in development until jhance's comment reminded me there is no such thing on windows.  From my understanding Integrity is kind of an obscure OS, but does anyone know about using sockets on it?
0
 
jhanceCommented:
Windows CreateProcess is not fork().  Windows CreateThread is also not fork().  

fork() just does not have a counterpart in Windows...

CreateProcess creates a NEW PROCESS.  If you are familiar with the system() function, you basically understand what CreateProcess does.  It starts a new program.

CreateThread create a NEW THREAD in the same process.  The thread shares everything with other threads in the same process EXCEPT its stack.

fork() does something else entirely.  It creates a new "thread" like CreateThread but, and this is a big but, the entire environment from the process that called fork() is duplicated for the child process/thread.  It's like a new process but also like a thread.  So it literally FORKS the running process into two identical processes.  The only way to tell who you are is the value return by the fork() function.  It's a PID for the parent (i.e. the original caller of fork) but it's NULL for the child, the duplicate process.
0
 
Chris1078Author Commented:
Yes, I realize that there is no windows fork.  I'm not asking for a "winfork"...I'm asking if CreateThread (not CreateProcess, couldn't remember the name) will allow me to create a seperate thread of execution that I can use to let a blocking socket run in while the main thread of execution continues and can simply check the newly created thread for messages when needed?  
0
 
AxterCommented:
listening...
0
 
wkmatt42Commented:
I can't imagine why not. I do pretty much the same thing for a server app on a unix box and it's been running for about two years.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now