vb.net - TCP/IP Client Connection Issue -


im having trouble tcp client. when client starts form send client.connect request me, when open form accept incoming request both connected , shows connected, when close clients form still shows connected though not.

    dim listener new tcplistener(4355)     dim client new tcpclient     dim message string      private sub listen()     try         listener.start()       catch ex exception      end try     end sub      private sub form1_load(sender object, e eventargs) handles      mybase.load     control.checkforillegalcrossthreadcalls = false     'ip.text = my.settings.ip     try         dim listening new thread(new threadstart(addressof listen))         listening.start()       catch ex exception         application.restart()     end try     sending1.focus()     end sub      private sub timer2_tick(sender object, e eventargs) handles      timer2.tick     if client.connected = false         label5.text = "disconnected"         label5.forecolor = color.red         sending1.enabled = false         client = listener.accepttcpclient() 'looping accept request     end if     if client.connected = true         label5.text = "connected"         label5.forecolor = color.green         sending1.enabled = true     end if     end sub 

you can use elseif.

if client.connected = false     label5.text = "disconnected"     label5.forecolor = color.red     sending1.enabled = false     client = listener.accepttcpclient()  elseif client.connected = true     label5.text = "connected"     label5.forecolor = color.green     sending1.enabled = true end if 

hope :)


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -