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

    • nacerbaaziz
      By nacerbaaziz
      Hello
      How are you
      I have a question, please.
      I've created a window and i need
      when i run the script if it detect an other copy from the same script was runing
       the script close the first copy Automatically and run a new copy
      I want an example to understand it
    • Nareshm
      By Nareshm
      How to repeat my script when my control class does not match ?
       
      My Script : winActivate ( " PS :: Version - 2.2.0.0  - [PS Bill]")                   ControlClick ( "PS :: Version - 2.2.0.0  - [PS Bill]", "", "[NAME:btnSavebyFP]")                   ControlSend(" PS :: Version - 2.2.0.0  - [PS Bill]", "", "[NAME:btnSavebyFP]", "{enter}")                   WinActive ("Verification Number Entry ::")                   ControlClick("Next >", "","[NAME:btnNext]") ;if   >>>> Control <<<<  does not match repeat my script, ;if match exit script  

      Class:    WindowsForm734a
      Instance:    15
      ClassnameNN:    WindowsForm34a15
      Name:    BillPrint
      Advanced (Class):    [NAME:BillPrint]
      ID:    7875
      Text:    
      Position:    39, 310
      Size:    1221, 306
      ControlClick Coords:    745, 20
      Style:    0x56010000
      ExStyle:    0x00000000
      Handle:    0x00000000000C0468
    • Nareshm
      By Nareshm
      Please Somebody Help me i am trying to create new script but, i don't know how to create it.

      I am Creating script like this :
      ; My script here [First Script]
      Check the internet connection, if internet connected then
      ; My Script here [Second Script]
      If internet not connected, wait for connect, after connected run my second script
      If Control id/windows/title matched do nothing and end/exit autoit script
      If Control id/windows/title not matched repeat my first and second script again until control id/windows/tittle not matched

      match with :
      >>>> Window <<<<
      Title:    PS :: Version - 2.8.0.0  - [PS Bill]
      Class:    WindowsForm734a
      Position:    -8, -8
      Size:    1382, 744
      Style:    0x17CD0000
      ExStyle:    0x00050100
      Handle:    0x0000000000130572
      >>>> Control <<<<
      Class:    WindowsForm734a
      Instance:    15
      ClassnameNN:    WindowsForm34a15
      Name:    BillPrint
      Advanced (Class):    [NAME:BillPrint]
      ID:    7875
      Text:    
      Position:    39, 310
      Size:    1221, 306
      ControlClick Coords:    745, 20
      Style:    0x56010000
      ExStyle:    0x00000000
      Handle:    0x00000000000C0468
       
    • Nareshm
      By Nareshm
      I create message box but i dont know how to add button action when i click it.

      Help for : Add script for Button : Left, Right, Right Finger
      example when i press Left finger button do Case $idNotepad
                      $iPID = WinActivate ( " :PS :: Version - 2.8.0.0  - [eFS Bill]")
                              ControlSend(" :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:btnReset]", "{esc}")
                              ControlClick ( " :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]")
                              ControlSend(" :DS  - eF:: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]", "^v")
                              ControlSend(" :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]", "{enter}")
      How to add like above ?
                    
                                                                sorry for my bad english
       
    • nacerbaaziz
      By nacerbaaziz
      Hi friends, I have a question, please.
      I have created a window containing a edit box
      I need to know how to change the keyboard language,
      e.g :
      if a user open the  script  it will be change the keyBord language   in window automatically into English
      I found more examples but didn't work with me .
      Note:  
       I use the windows 10 os
      Please help me .
      thanks in advance to all
      with my Greetings and my appreciation for all users and admins