OSDev.org

The Place to Start for Operating System Developers
It is currently Mon May 20, 2024 9:16 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re:Client/Server
PostPosted: Sun Nov 28, 2004 4:45 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 9:01 am
Posts: 842
Candy wrote:
... or dynamic_cast<ClientSocket>(object) it to the right type. If neither works, you are trying a really invalid assignment. Don't do that.


Does that mean I should write a constructor for the ClientSocket class that accpets a Socket as argument??

_________________
Only Human


Top
 Profile  
 
 Post subject: Re:Client/Server
PostPosted: Sun Nov 28, 2004 4:56 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 9:01 am
Posts: 842
Another thing I would also like to know is how to shutdown a server (not just using 'kill') from the command line itself. This is what i think should be done, please let me know if its right.
The server checks for command line args (CLA's) and if none are found then just start normally, by that i mean that the server will fork() a thread that will contain the execution logic of the server. This thread keeps on running forever (so i think i should ignore all interrupts??)
The program then returns to the command line (i think just not using wait() in the parent will make this possible ??
To shutdown i run the server with an CLA named say '-stop'
Now my problem here is how do i know which thread to kill if i am going to use 'kill()'

Or does anyone else have a better way of doing this whole thing??

_________________
Only Human


Top
 Profile  
 
 Post subject: Re:Client/Server
PostPosted: Sun Nov 28, 2004 10:29 am 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 11:33 pm
Posts: 3882
Location: Eindhoven
Neo wrote:
Candy wrote:
... or dynamic_cast<ClientSocket>(object) it to the right type. If neither works, you are trying a really invalid assignment. Don't do that.


Does that mean I should write a constructor for the ClientSocket class that accpets a Socket as argument??

Well.... no.

The dynamic_cast is identical to a normal cast ((ClientSocket *)object), except that it throws an exception if the object casted really isn't a client socket after all.

If you want your ServerSocket class to return ClientSocket's, make it return ClientSockets. If you want it to return Sockets, make it return Sockets and expect them in the receiving code. If you want it to return ClientSockets, but don't have a constructor for a client socket based on just a file descriptor, make one that does and make it protected, then make ServerSocket a friend of ClientSocket.

These are (afaik && imho) your best options.


Top
 Profile  
 
 Post subject: Re:Client/Server
PostPosted: Mon Nov 29, 2004 8:01 am 
Offline
Member
Member

Joined: Wed Oct 18, 2006 11:59 am
Posts: 1600
Location: Vienna/Austria
shouldn't the declaration of clientsocket cs be a pointer? like so: ClientSocket *cs; ?

_________________
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image


Top
 Profile  
 
 Post subject: Re:Client/Server
PostPosted: Mon Nov 29, 2004 11:16 am 
On solaris when i need to compile my Socket programs i need to add the-lxnet or -lsocket arguments along with g++.
Why is this so? what are the actual libraries being linked in. I need to create a makefile for this but cant seem to get it done. Any help appreciated.


Top
  
 
 Post subject: Re:Client/Server
PostPosted: Mon Nov 29, 2004 11:33 am 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 11:33 pm
Posts: 3882
Location: Eindhoven
rich_m wrote:
On solaris when i need to compile my Socket programs i need to add the-lxnet or -lsocket arguments along with g++.
Why is this so? what are the actual libraries being linked in. I need to create a makefile for this but cant seem to get it done. Any help appreciated.



The -lsocket adds libsocket (from probably /usr/lib/* or /lib/*) to your program.

You do want to use them directly in your makefile.

PS: the solaris systems I can use also require -lnsl


Top
 Profile  
 
 Post subject: Re:Client/Server
PostPosted: Tue Nov 30, 2004 7:27 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 9:01 am
Posts: 842
does the -lxnet do the same?

_________________
Only Human


Top
 Profile  
 
 Post subject: Re:Client/Server
PostPosted: Wed Dec 01, 2004 2:46 am 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7615
Location: Germany
-lanything links to libanything.

_________________
Every good solution is obvious once you've found it.


Top
 Profile  
 
 Post subject: Re:Client/Server
PostPosted: Wed Dec 01, 2004 5:38 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 9:01 am
Posts: 842
Would be nice if anyone on Solaris could give me a makefile for some socket programming demo or something.

_________________
Only Human


Top
 Profile  
 
 Post subject: Re:Client/Server
PostPosted: Wed Dec 01, 2004 6:24 am 
Offline
Member
Member

Joined: Wed Oct 18, 2006 11:59 am
Posts: 1600
Location: Vienna/Austria
maybe this is of use: http://pont.net/socket/

this line:
Code:
solaris : gcc -Wall -o foo foo.c -lsocket -lnsl

might be helpful.

_________________
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image


Top
 Profile  
 
 Post subject: Re:Client/Server
PostPosted: Wed Dec 01, 2004 7:11 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 9:01 am
Posts: 842
i wanted to create the object files separately to facilitate easier deployment.
Any help on that front?

_________________
Only Human


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2

All times are UTC - 6 hours


Who is online

Users browsing this forum: Majestic-12 [Bot], nullplan and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group