Does that mean I should write a constructor for the ClientSocket class that accpets a Socket as argument??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.
Client/Server
Re:Client/Server
Only Human
Re:Client/Server
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??
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
Re:Client/Server
Well.... no.Neo wrote:Does that mean I should write a constructor for the ClientSocket class that accpets a Socket as argument??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.
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.
-
- Member
- Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Re:Client/Server
shouldn't the declaration of clientsocket cs be a pointer? like so: ClientSocket *cs; ?
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
BlueillusionOS iso image
Re:Client/Server
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.
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.
Re:Client/Server
The -lsocket adds libsocket (from probably /usr/lib/* or /lib/*) to your program.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.
You do want to use them directly in your makefile.
PS: the solaris systems I can use also require -lnsl
Re:Client/Server
-lanything links to libanything.
Every good solution is obvious once you've found it.
Re:Client/Server
Would be nice if anyone on Solaris could give me a makefile for some socket programming demo or something.
Only Human
-
- Member
- Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Re:Client/Server
maybe this is of use: http://pont.net/socket/
this line:
might be helpful.
this line:
Code: Select all
solaris : gcc -Wall -o foo foo.c -lsocket -lnsl
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
BlueillusionOS iso image
Re:Client/Server
i wanted to create the object files separately to facilitate easier deployment.
Any help on that front?
Any help on that front?
Only Human