UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » C++
  • » client server application on UNIX & WINDOWS

#1 2004-08-21 12:27 PM

lenna
Member
Registered: 2004-08-21
Posts: 77

Re: client server application on UNIX & WINDOWS

Hi,

I want to write a client server application (c++), so that some clients will run on WINDOWS while others on UNIX. I need to write the code so it will be multiplatform, meaning the same code for different clients with different OS (UNIX, WINDOWS). the problem is different OS use different libraries/ function libraries. does anybody know any pre compilation methods/ other that can help me identify the OS of a current client and use the relevant functions accordingly???

something like...

#if OS == UNIX
           read_UNIX_Socket()
#elseif OS == WINDOWS
          read_WINDOWS_Socket()

thanks a lot for your help,

lenna

Offline

#2 2004-08-21 01:29 PM

Nope
Administrator
From: Germany
Registered: 2004-01-24
Posts: 385
Website

Re: client server application on UNIX & WINDOWS

You should encapsulate all the low level code in classes. At least gather all
the os dependend code in them. That will make it a lot easier to read your
code afterwards as you only have to decide which one to take at link time
and it won't show directly in your code.

Offline

#3 2004-08-21 03:37 PM

lenna
Member
Registered: 2004-08-21
Posts: 77

Re: client server application on UNIX & WINDOWS

Offline

#4 2004-08-21 08:31 PM

Nope
Administrator
From: Germany
Registered: 2004-01-24
Posts: 385
Website

Re: client server application on UNIX & WINDOWS

Offline

#5 2004-08-21 09:40 PM

lenna
Member
Registered: 2004-08-21
Posts: 77

Re: client server application on UNIX & WINDOWS

Hi Nope,
thanks for your kind answer. I'll try it tommorow...
me

Offline

#6 2004-08-22 03:19 AM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: client server application on UNIX & WINDOWS

Don't do fancy things, use recv/send/select and you should be relative safe. I have a link to a site with a good comparison between unix and Windows socket programming, it's on the other pc so I'll post it tomorrow.

Offline

#7 2004-08-22 01:19 PM

lenna
Member
Registered: 2004-08-21
Posts: 77

Re: client server application on UNIX & WINDOWS

thanks i3839

Offline

#8 2004-08-22 03:51 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: client server application on UNIX & WINDOWS

Offline

  • Index
  • » C++
  • » client server application on UNIX & WINDOWS

Board footer

Powered by FluxBB