Solved

Sockets portability

Posted on 2001-07-03
8
351 Views
Last Modified: 2010-05-18
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
Comment
Question by:Chris1078
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 

Accepted Solution

by:
wkmatt42 earned 50 total points
ID: 6249880
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
 

Author Comment

by:Chris1078
ID: 6249944
Eventually, it will be running integrity OS.
0
 
LVL 32

Expert Comment

by:jhance
ID: 6249949
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!

 

Author Comment

by:Chris1078
ID: 6249993
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
 
LVL 32

Expert Comment

by:jhance
ID: 6250101
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
 

Author Comment

by:Chris1078
ID: 6250316
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
 
LVL 30

Expert Comment

by:Axter
ID: 6251115
listening...
0
 

Expert Comment

by:wkmatt42
ID: 6253337
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

Technology Partners: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question