#The C++ server "sees" the connection, and the client can "see" when
the server goes away, but the communication in between isn't working
I'm using tcl8.4 on rhel-4-0-ia32
> set socket [socket "129.57.228.105" 32500]
sock5
> puts $socket "LISTEN" (#no errors, but server never sees this)
> flush $socket
> gets $socket line (#never returns from "gets")
Is there something special needed in the C++ server side that may be
missing?
Any help would be truly appreciated.
Michele
[snip]
> Is there something special needed in the C++ server side that may be
> missing?
C++ has no a "standard" socket library. There are lots of C++ (and C)
libraries for sockets (plus raw socket manipulation). Once the data is
in the socket, it is just data, it has no relation with the programming
language used for putting it on the wire.
You need to check the *exact* requirements of your C++ server (data
formats, protocols, etc). For instance: is "LISTEN" supposed to be
followed by a newline character? Tcl's `puts' does that. Try:
puts -nonewline $socket"LISTEN"
If your C++ server-side code is simple, post it here, and I'll look at
it.
HTH.
--
Oscar
Yes. TclLib has many examples of this (smtp, http, ftp, ntp, nntp, ...).
> I've seen lots of
> examples of both client and server being written in tcl, and it looks
> straight forward, but when I try to talk to the C++ server...
>
> #The C++ server "sees" the connection, and the client can "see" when
> the server goes away, but the communication in between isn't working
>
> I'm using tcl8.4 on rhel-4-0-ia32
>
>> set socket [socket "129.57.228.105" 32500]
> sock5
>> puts $socket "LISTEN" (#no errors, but server never sees this)
>> flush $socket
>> gets $socket line (#never returns from "gets")
>
> Is there something special needed in the C++ server side that may be
> missing?
> Any help would be truly appreciated.
Well the C++ side is much harder then the Tcl side. Do you have experience
with writing C++ server code?
You may want to post your C++ code here.
--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+
I once worked with a MS windows programmer trying to get client server
working, and it was much simpler on Unix.
Things that worked for us:
Stick to an ASCII protocol
Write an alternate simple server in Tcl which will eventually be
replaced
When in doubt, test the server by using telnet systemname portnumber
from the client side
Almost all the problems were caused by the libraries trying to emulate
sockets, and in the end we decided to do the sensible thing, and run
the Unix machines as servers (which was back to front as far as the
application design was concerned).
Dave
> I once worked with a MS windows programmer trying to get client server
> working, and it was much simpler on Unix.
>
> Things that worked for us:
> Stick to an ASCII protocol
> Write an alternate simple server in Tcl which will eventually be
> replaced
> When in doubt, test the server by using telnet systemname portnumber
> from the client side
You can do exactly this on Windows too. Probably, the Tcl code you wrote
for Unix will work on Windows with no changes. (Which, of course, is a
merit of Tcl. But I can't guess why you think that ASCII protocols are
more difficult to implement on Windows)
> Almost all the problems were caused by the libraries trying to emulate
> sockets,
The Windows Socket API is a bit different from Unix, but it is sockets
all the way.
[snip]
--
Oscar
I totally agree.
> But I can't guess why you think that ASCII protocols are
> more difficult to implement on Windows)
No, I am not saying that they are more difficult; I am saying that
even if they were more difficult, the choice should favour ASCII.
>
> > Almost all the problems were caused by the libraries trying to emulate
> > sockets,
>
> The Windows Socket API is a bit different from Unix, but it is sockets
> all the way.
They may be now. This was at a time (early 90's) when MS windows had
just discovered networking, and the methodologies out of 'Stevens -
Unix network programming' were useless under Windows. I am hoping that
for the original poster's sake they better now. Inherent issues in the
OS made life 'interesting'.
However, from a personal point of view, the experience was beneficial
since I found out the easy way that I would never want to switch from
*nix to MS windows, and that C would never be my preferred language,
let alone C++.
Dave
>>But I can't guess why you think that ASCII protocols are
>>more difficult to implement on Windows)
>
>
> No, I am not saying that they are more difficult; I am saying that
> even if they were more difficult, the choice should favour ASCII.
I have just converted an embedded app that transfered binary structures
for talking to with no version information to plain text ascii.
Added basic introspection to the protocol too.( basically a restricted
jim interpreter behind a socket )
Testability and robustness are greatly improved.
In general, on all platforms, binary protocols are a bit harder to
implement. OK, maybe not to do the first draft, but text protocols are
far easier than binary ones to debug. (A protocol's not implemented in
my book until it's done right.) The big advantage of a binary protocol
is that it is easier to make it go fast, but that doesn't make it any
easier to correctly implement.
Tcl's networking code is good though. From the scripting level, it
works *the same* on all platforms, which is great! (Well, so long as
you're not asking to create low-numbered server sockets.)
Donal.