Yes... I'm connecting from Linux(client) to NT( as server).
If I use NT or Win98 as clients, the the connections work normally.
What happens when I use linux to connect to NT, frequently, I get the
expected socket accept() when the client in linux connects. The NT
server goes off and starts off a thread (w/ the socket passed in) to
process the data.
However, immediately after, the NT server receives another accept.
When it then goes to read data, it finds that there is no data, and
the socket recv() returns 0... indicating non data/closed connection.
I have found out that when using perl (client) , if I put a 2 second
sleep after opening the port, the bad connections are reduced to
about 1 in 10.... from about 1 in 3..
Both the C++ class and the Perl script exhibit the same problem on
linux... Both work properly when the same code is run from NT... It's
the same code....
Is there anything I'm missing on Delays, shutdown (I'm not using
this), or resetting ports that should be needed or done what I'm not
aware of???
The same perl script (unchanged) works properly on a tested solaris
box...
here's what I'm using to connect.... .
//////////////////////////////////////
package xx;
use Socket;
use Sys::Hostname;
$delimiter = "\001";
$MODE_BLOCK = 0;
$MODE_NOBLOCK = 1;
$ERR_HOST_NOT_SPECIFIED = 1;
$ERR_PORT_NOT_SPECIFIED = 2;
$ERR_SOCKET_NOT_OPEN = 3;
$ERR_INVALID_LOGIN = 4;
$ERR_SERVER_CLOSED_CONNECTION = 5;
$ERR_SOCKET_ALREADY_OPEN = 6;
$ERR_AGENT_NOT_FOUND = 50;
$ERR_SCRIPT_NOT_FOUND = 51;
$ERR_CANT_CONNECT_TO_AGENT = 52;
$ERR_AGENT_CONNECTION_LOST = 53;
$ERR_SOCKET_CONNECTION_FAILED = 80;
$ERR_SOCKET_BIND_FAILED = 81;
$ERR_SOCK_INITIALIZATION_FAILED = 99;
$ERR_PREFIX = "!!--##";
$SIG{'Int'} = 'dokill';
sub dokill
{
kill 9, $child if $child;
Quote:}
sub new
{
return bless {};
Quote:}
sub Open
{
my $self = shift;
# Initialize Local copies for simplicity
my $debug = $self->{m_debug};
# Initialize
$self->{m_lasterror} = 0;
$self->{m_gwCon} = 0;
$self->{m_output} = "";
$self->{m_bOpen} = 0;
($name, $aliases, $proto) = getprotobyname('tcp');
($name, $aliases, $port) = getservbyname($port,'tcp') unless $port
=~/^\d+$/;
if ($server eq "")
{
$self->{m_lasterror} = $ERR_HOST_NOT_SPECIFIED;
return $self->{m_lasterror};
}
if ($port == 0)
{
$self->{m_lasterror} = $ERR_PORT_NOT_SPECIFIED;
return $self->{m_lasterror};
}
if ($debug)
{
print "Using port $port to connect to server on host
$server...\n";
}
($name,$aliases,$type,$len,$thisaddr) = gethostbyname(hostname());
($name, $aliases,$type,$len,$thataddr) = gethostbyname($server);
if (socket(S,AF_INET, SOCK_STREAM, $proto))
{
if ($debug)
{
print "Socket creation succeeded.\n";
}
}
else
{
$self->{m_lasterror} = $ERR_SOCK_INITIALIZATION_FAILED;
return $self->{m_lasterror};
}
$sockaddr = 'S n a4 x8';
$this = pack($sockaddr, AF_INET, 0, $thisaddr);
$that = pack($sockaddr, AF_INET, $port, $thataddr);
if (bind(S, $this))
{
if ($debug)
{
print "Bind succeeded.\n";
}
}
else
{
$self->{m_lasterror} = $ERR_SOCKET_BIND_FAILED;
return $self->{m_lasterror};
}
if (connect(S, $that))
{
if ($debug)
{
print "Connect succeeded.\n";
}
}
else
{
$self->{m_lasterror} = $ERR_SOCKET_CONNECTION_FAILED;
return $self->{m_lasterror};
}
select(S);
$| = 1;
select(STDOUT);
$slogin = $username . "\t" . $password;
print S $slogin;
while(sysread(S,$output,65000) == 0)
{
sleep(1);
}
if ($output eq "1")
{
$self->{m_gwCon} = S;
$self->{m_bOpen} = 1;
return 0;
}
else
{
$self->{m_lasterror} = $ERR_INVALID_LOGIN;
return $self->{m_lasterror};
}
Quote:}
////////////////////////////////////
When this connects, it sends a username and password, then is supposed
to receive a "1" or a "0" to indicate whether the username is
valid.... I haven't really seen anything wrong w/ the code, since it
does work on the pc w/out any changes...
Is there any type of Port configuration changes/initialization I might
need???
Oh, please do send me the examples you mentioned....
thanks,
sergio olivas
On Wed, 24 Nov 1999 22:01:36 +0000,
>On Tue, 23 Nov 1999 08:36:54 -0800, Sergio Olivas blurted:
>>I'm using linux (rh6.1) connecting to NT server (or Workstation)...
>>I'm doing socket io... with the regular
>>bind/listing/accept/close, etc...
>as you do when you are doing socket operations :-))
>>when I connect toNT, I always get two accepts....
>>The first one is valid, and I get the data there and back ok...
>>The second one basically connects and has no data and then
>>disconnects.... -- this is the one I have no idea why it's
>>happening...
>>Can anywone tell me why this is so...
>maybe it's a feature of NT :)
>R U using linux to connect to NT or the other way around?
>how exactly are u making the connection?
>ie: u must be doing something like this:
>create socket
>bind socket to port
>listen for connections
>accept connections
>fork process to handle connection
>go back to listening for connections
>If you like, I could send you some simple server and client code if u
>think that would help