socket programming

  • Thread starter Thread starter bhargavi
  • Start date Start date
B

bhargavi

hi i am doing socket programming. how do i access the
value of a variable in one class in another class?
is it possible to copy a socket descriptor of one class
to a socket descriptor of another class? if so how to do
it?

please reply soon. any help is appreciated
 
bhargavi said:
hi i am doing socket programming. how do i access the
value of a variable in one class in another class?
Yes, either make 'friend' method if the variables are private or simply to
member to member assignment if members are public.
is it possible to copy a socket descriptor of one class
to a socket descriptor of another class? if so how to do
it?
'sd' is just a handle, you can copy it from a class to another.
However if you're copying from a process to another try duplicating the 'sd'
instead of copying it.

HTH
Elias
 
bhargavi said:
hi i am doing socket programming. how do i access the
value of a variable in one class in another class?

You don't. The idea behind classes is to encapsulate data and provide a
high-level interface that lets clients specify *what* the want to do
rather than *how* they want to get things done. Class variables should
always be manipulated by member functions.
is it possible to copy a socket descriptor of one class
to a socket descriptor of another class? if so how to do
it?

Yes, you can copy your socket descriptors all around the place, but the
resulting code will be a mess. If you don't want to hide low-level
details behind a class interface, you can just as well program in pure C.

For ample information on object-oriented socket programming, try

http://www.cs.wustl.edu/~schmidt/ACE.html

Gerhard Menzl
 
Back
Top