Sign in to follow this  
Followers 0
Turtlix21

TCP, UDP problem with receiving data

8 posts in this topic

#1 ·  Posted (edited)

I've a problem with receiving data on my PC by TCP and UDP. I can send data to another computer, but can't receive it.

I'm not shure where is the problem (on PC or on "another comupers")

This is client code:

;TCP client
TCPStartup()
$socket = TCPConnect("192.168.0.18", 7777) ;try to connect to server and save number of socket
If $socket = -1 Then ;if $socket = -1 then error
   MsgBox(16, "Error:", "Can't connect to server")
EndIf
$sendedBytes = TCPSend($socket, "nothing here :)") ;send message to connected socket
If $sendedBytes = 0 Then ;if receiving data TCPSend(...) = 0 then error
   MsgBox(16, "Error", "Can't send message")
EndIf
TCPCloseSocket($socket)
TCPShutdown()

and server code:

;TCP server
TCPStartup()
$mainsocket = TCPListen("192.168.0.18", 7777) ;making main receiving socket
While 1 ;receiving loop
   $acceptedSocket = TCPAccept($mainsocket) ;possible connection to accept
   If $acceptedSocket <> -1 Then
      $receivedData = TCPRecv($acceptedSocket, 1024) ;if main socket is connected then receive message
      MsgBox(64, "Received message!", "Message: " & $receivedData)
      TCPCloseSocket($acceptedSocket) ;close open connecion
   EndIf
WEnd
TCPShutdown()

 

When server is on PC I can't receive any messages from any other computers.
When client is on PC I can receive messages on any another computer.

I tried to turn off antiviruses and windows firewall but it did't change anything

 

EDIT:

Error code from client from TCPConnect is 10060 (connection time out) and from TCPSend: 10038

I've found something about 10060 error code, Microsoft says "Connection timed out. A connection attempt failed because the connected party did not properly respond after a period of time, or the established connection failed because the connected host has failed to respond."

So it means that the problem is with time of response but it makes no sense couse "another computer" is Virtual Machine with bridge internet connection from PC (pings beetwen PC  and VM are lower than 1ms.

About 10038 error code microsoft says that this is problem with socket and it actually makes sense.

 
Edited by Turtlix21

Share this post


Link to post
Share on other sites



Works good if server and client are on the PC.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

No, they haven't same IP (PC's IP: 0.18 and VM's IP: 0.21), but in both of this codes I have to set up servers IP (in server I'm setting on what ip server will be working, and on client to what server I'm trying to connect).

Edited by Turtlix21

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

yep, what I meant was: you said when server is on VM, everything works (so client\server scripts have the right 0.18 IP), but when server is on PC it doesn't work, in this last case, have you kept attention to change accordingly the inserted client\server IPs to 0.21?

Also, it seems stupid but... Server must be started before client execution :P

Edited by j0kky

Share this post


Link to post
Share on other sites

When server is on VM, IPs are 0.21(it's VM's IP), and it's working.
When server is on PC, IPs are 0.18 (it's PC's IP), and it's not working.

So everything should be good.

 

Yeah, i know that server have to be started first :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • Valnurat
      By Valnurat
      I hope my title is good enough.
      I'm using the ADO UDF and I have question regarding editing SQL records with this UDF.
      The owner of the UDF suggested an idea, but maybe there is another trix.
    • Valnurat
      By Valnurat
      I have a SQL db. I would like to view the content in a control. Like a table. The control should have the option to show every 2nd line in another color. When you pick a "cell" it should pick the whole row. When you dobbelt click on the row another windows should popup with the content from the row.
      What view control can do that?
    • Valnurat
      By Valnurat
      How do I access a sql database for inserting and reading?
    • Valnurat
      By Valnurat
      I'm trying to get some info from dell.com page. I use a servicetag to find the computer. From the computerinfo I would like to get the "Shipping Date", but the date is on the next "cell".
      I have done this and I don't know if this is correct aproach, but I do get some info out.
      I just don't know how to "jump" to the next cell.
       
      #include <IE.au3> #include <MsgBoxConstants.au3> Local $oIE = _IECreate("http://www.dell.com/support/home/dk/da/dkbsdt1/product-support/servicetag/gnn5f12/configuration") Local $oTds = _IETagNameGetCollection($oIE, "td") Local $sTxt = "" For $oTd In $oTds $sTxt &= $oTd.innertext & @CRLF Next MsgBox($MB_SYSTEMMODAL, "Form Input Type", " Types :" & @CRLF & $sTxt) _IEQuit($oIE) I have seen something like this in VBscript
      Cell.NextSibling.NextSibling.innertext Is there someone who could help me.
       
    • srini
      By srini
      I am trying to automate the windows GUI application, in the main window of this application i have one gridview control in it, and when you click on the any row of the gridview separate windows will be opened based on the selection of the row. 
      we have our existing framework implemented using the core java,  i have used AutoITX4java.jar file to automate the above application. and controlCommandListView options used to click on grid view row item. nothing is working. 
      my question is AutoIT can be used/called directly from java file??? instead of using the AutoITX4java.jar file???
      AutoIT supports GridView automation??? like gridview count and gridivew row item click event automation ect...????
      Any help would be really appricate!!
      Thanks
      Srini
      srini20483@gmail.com