tcpclient

  • Thread starter Thread starter cloud
  • Start date Start date
C

cloud

Hello all,

i am trying to connect to a remote host.

Public tcpConnection As Boolean = False
Public tcpClientConnection As New System.Net.Sockets.TcpClient

tcpClientConnection.Connect("192.148.111.233", 7)
tcpConnection = tcpClientConnection.Connected

my problem is, my application should detect if some other application
has already connected to the specified ip and port. if not then
connection with my application should be established else not.

if i implement as shown in the above code...tcpConnection always true.

Thank you for any suggestion
 
Do you mean on the same machine ? The command line tool netstat does this so
you should have an API allowing to get this info.

For now I'm not sure what is the problem. Port 7 is a well known port and
shouldn't be used for your own purpose... If you really want to use the echo
service I'm not a tcpclient expert but I don't think you should have any
problem if another application is using the same service ?!...

What is the problem you are experiencing when the other app uses the same
port ?

--
Patrice

"cloud" <[email protected]> a écrit dans le message de groupe de
discussion :
(e-mail address removed)...
 
Do you mean on the same machine ? The command line tool netstat does thisso
you should have an API allowing to get this info.

For now I'm not sure what is the problem. Port 7 is a well known port and
shouldn't be used for your own purpose... If you really want to use the echo
service I'm not a tcpclient expert but I don't think you should have any
problem if another application is using the same service ?!...

What is the problem you are experiencing when the other app uses the same
port ?

--
Patrice

"cloud" <[email protected]> a écrit dans le message de groupe de
discussion :
(e-mail address removed)...

If another application is using the the machine with ip
192.148.111.233 and the port, my application should be able to raise
the error.
I need this because, My application should be able to raise a message
to the user saying some other application is using the machine with
that ip
How can this be done..
 
If another application is using the the machine with ip
192.148.111.233 and the port, my application should be able to raise
the error.
I need this because, My application should be able to raise a message
to the user saying some other application is using the machine with
that ip
How can this be done..

Still unclear. For now my understanding would be that for some unknown
reason you want your service to be able to handle single connected client at
a time. If this is your own service you should be able to include this logic
in your service?

If this is not your own service I don"t think you can do this easily as by
design if the service was made to serve multiple clients, it would be uneasy
to change this... The best you could do then would be perhaps to have your
own service acting as a relay for the real service. Still not sure what is
the problem if multiple machines are using the same service.

If you meant the client machine, thne this is the OS job. The OS should
display a message when it detects an IP address conflict...

A networking group might be more usefull...
 
Still unclear. For now my understanding would be that for some unknown
reason you want your service to be able to handle single connected clientat
a time. If this is your own service you should be able to include this logic
in your service?

If this is not your own service I don"t think you can do this easily as by
design if the service was made to serve multiple clients, it would be uneasy
to change this... The best you could do then would be perhaps to have your
own service acting as a relay for the real service. Still not sure what is
the problem if multiple machines are using the same service.

If you meant the client machine, thne this is the OS job. The OS should
display a message when it detects an IP address conflict...

A networking group might be more usefull...


sorry for not making it clear...we have a industrial printer and i am
making a tool to connect it remotely
when some other tool is using the remotehost (printer) with the ip ,
and when i am trying to connect to it...my application gets blocked.
if I close that unknown application and try connectiing
again...everything works fine.
So my problem is..when a client already connected to the printer with
one of our tool and tried to connect with my application also.....so
my application should be able to generate a certain message so that he
disconnects other application.
so this is the problem...i hope now it is clear..thank you
 
Not sure what is the protocol used ? Do you have the protocol communication
documentation ?

Being unable to *use* the printer and not being able to connect to the
printer is not necessarily the same. Have you checked the response ? The
printer could perhaps be able to always respond to a connection request but
in one case with a "OK send me your data" response or with a "I'm busy right
now and can't process whatever you'll send me, try again later" response...

What makes me think that is that if you can' connect you are unable to
distinguish between the printer being physically off or unplugged from the
network and the printer being busy, currently offline, with an empty tray
etc... and not accepting *printing* requests at this time (but you can
likely still connect).

AFAIK we used an IP printer once and I don't think we ever saw this
behavior. We just used the drivers and the printer was able to queue jobs...

So my girst step would be to make sure that the printer is supposed to
refused a TCP/IP connection. IMO it would be rather accept other TCP/IP
connection but you have likely a response that tells the printer is busy...

Sorry for the poor help...
 
According to :http://web.mit.edu/source/third/lprng/doc/LPRng-HOWTO-3.html, it doesn't
seems to be your job but that in most cases the printer will just refuse the
connection if busy...

Also not sure but the code you shown uses port 7 which is the standard port
for another service
(http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers).

To start with, are you sure your printer uses port 7 ?

my problem is if printer is busy...it queus the requests whatever i
send
but to the user...it seems the application is hanged...to avoid
that..what should be done.
 
Back
Top