AutoHotkey Community

It is currently May 26th, 2012, 8:49 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 131 posts ]  Go to page Previous  1 ... 4, 5, 6, 7, 8, 9  Next
Author Message
 Post subject:
PostPosted: May 22nd, 2008, 5:00 am 
Hi there. I am still having trouble.

So, you say if one of us runs the Server script configured like this below

(I am excerpting this from the original code in this thread)

Code:
; -------------------------------------------------
; ------------SERVERSCRIPT------------------
; -------------------------------------------------
; CONFIGURATION SECTION:

; Specify Your own Network's address and port.
Network_Address = 70.74.71.100
Network_Port = 8765



I am assuming from the comment on this code, I am to put my PUBLIC IP address in that Network_Address spot and a port I want to open.

And my friend runs the Client in another part of town,....

Code:
; -------------------------------------------------
;-----------CLIENTSCRIPT----------------------
; -------------------------------------------------
; CONFIGURATION SECTION:

; Specify address and port of the server.
Network_Address = 70.74.71.100
Network_Port = 8765


So, my buddy runs this part of the script... and that should have my PUBLIC IP and same port. ....and so then, upon him clicking CONNECT from the client script, it should reach my end, and connect to my server script?

Right? The problem I am facing is, when I run the Server script it just crashes. I am getting a bind() indicated Winsock error 10049 message. Same thing happens with him if he attempts to run the server script. However, I am not running nor my friend is running any firewalls and we are on the same ISP. Further, we can actually ping each other, and so from DOS when we PING each other we see data there at that level.... so there are no blocks in theory between us.

So what are we doing wrong? If I put something like 127.0.0.1 on the Server Script, it just sends messages to itself... that works.

..... Any ideas on what we could be doing wrong, and need to do to make this function over the Internet? :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 22nd, 2008, 5:50 am 
Offline

Joined: May 14th, 2008, 9:48 pm
Posts: 110
either put 127.0.0.1 or your local IP address for the server
________
Iolite vaporizer


Last edited by jmanx on February 10th, 2011, 9:32 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 22nd, 2008, 8:10 am 
Lexikos wrote:
It seems Zippo() skipped over half my post. :roll:

I'll try to make it more obvious next time :P


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 22nd, 2008, 9:26 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
jmanx wrote:
either put 127.0.0.1 or your local IP address for the server
IIRC, the address in the server is the address of the local interface it binds to. If it binds to localhost (127.0.0.1), it will only accept connections from the local machine. Binding to 0.0.0.0 on the other hand, should allow connections from any network.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 22nd, 2008, 4:56 pm 
Offline

Joined: February 6th, 2008, 5:36 am
Posts: 23
Location: Dallas
Thank you all! Now it works and I appreciate all the assistance.:D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2008, 12:12 am 
jmanx wrote:
It works now thanks.
Is there anyway to define when a certain address disconnects though?


Hmm... interesting approach. I was thinking more functionally, disconnecting from the current client connected to. (I.e. path > press CONNECT to connect > DISCONNECT to disconnect > and CONNECT to reconnect, ... ) How would this be done?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 4th, 2008, 7:39 pm 
Offline

Joined: February 6th, 2008, 5:36 am
Posts: 23
Location: Dallas
I am wondering if anyone has had luck prusing the notions U90 presented above. I think it would be very useful to have this capability inside this TCP/IP function, for re-connection to server without reloading script :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2008, 6:44 pm 
Can anyone see if this last requests is possible? It seems like a easy to do thing, but appears to be harder in execution than it seems. :?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 12th, 2008, 7:57 pm 
please? :oops: :cry: , i would very much like to make this work for a project if anyone knows! :D


Zebra.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 15th, 2009, 9:19 am 
Offline
User avatar

Joined: May 10th, 2007, 10:54 am
Posts: 649
Location: .switzerland
I tryed to convert the ConnectToAddress(IPAddress, Port) to allow IPv6 adr. My problem is, I have to create a ipv6 adrsocket-struct.
Code:
/**************************************************************
connect to a IPv6
***************************************************************
*/
ConnectToAddress(IPAddress, Port){
    VarSetCapacity(wsaData, 32)  ; The struct is only about 14 in size, so 32 is conservative.
    ;ipv6 requires wsock 2.2
    WSOCK_20    := 0x0002 ;wsock 2.0
    WSOCK_22    := 0x0202 ;wsock 2.2
    result := DllCall("Ws2_32\WSAStartup", "UShort", 0x0202, "UInt", &wsaData) ; Request Winsock 2.0 (0x0202)
    ; Since WSAStartup() will likely be the first Winsock function called by this script,
    ; check ErrorLevel to see if the OS has Winsock 2.2 available:
    if (ErrorLevel){
        MsgBox WSAStartup() could not be called due to error %ErrorLevel%. Winsock 2.0 or higher is required.
        return -1
    }
    if (result){  ; Non-zero, which means it failed (most Winsock functions return 0 upon success).
        MsgBox % "WSAStartup() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError")
        return -1
    }

    AF_INET     := 2    ;for IPv4
    AF_INET6    := 23   ;for IPv6
    SOCK_STREAM := 1
    IPPROTO_TCP := 6
    socket := DllCall("Ws2_32\socket", "Int", AF_INET6, "Int", SOCK_STREAM, "Int", IPPROTO_TCP)
    if socket = -1
    {
        MsgBox % "socket() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError")
        return -1
    }

;...until here it works, but now I need the sockaddr_in6 Data-struct.

   
    /* struct def postet by Lexicos
typedef struct sockaddr_in6 {
    ADDRESS_FAMILY sin6_family; // AF_INET6.
    USHORT sin6_port;           // Transport level port number.
    ULONG  sin6_flowinfo;       // IPv6 flow information.
    IN6_ADDR sin6_addr;         // IPv6 address.
    union {
        ULONG sin6_scope_id;     // Set of interfaces for a scope.
        SCOPE_ID sin6_scope_struct;
    };
} SOCKADDR_IN6_LH, *PSOCKADDR_IN6_LH, FAR *LPSOCKADDR_IN6_LH;

typedef struct in6_addr {
    union {
        UCHAR       Byte[16];
        USHORT      Word[8];
    } u;
} IN6_ADDR, *PIN6_ADDR, FAR *LPIN6_ADDR;
   
    */


/* THIS IS IPv4 sockadr Struct
    ; Prepare for connection:
    SizeOfSocketAddress = 16
    VarSetCapacity(SocketAddress, SizeOfSocketAddress)
    InsertInteger(2, SocketAddress, 0, AF_INET)   ; sin_family
    InsertInteger(DllCall("Ws2_32\htons", "UShort", Port), SocketAddress, 2, 2)   ; sin_port
    InsertInteger(DllCall("Ws2_32\inet_addr", "Str", IPAddress), SocketAddress, 4, 4)   ; sin_addr.s_addr
*/

    ; Attempt connection:
    if DllCall("Ws2_32\connect", "UInt", socket, "UInt", &SocketAddress, "Int", SizeOfSocketAddress)
    {
        MsgBox % "connect() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError") . "?"
        return -1
    }
    return socket  ; Indicate success by returning a valid socket ID rather than -1.
}


I tried a bit, but I doesnt work. So, is there a struct-pro here, who can help me to create this ipv6-struct?

greets
IsNull


EDIT:
Maby this could be of interest:
http://msdn.microsoft.com/en-us/library/ms737937(VS.85).aspx

WSAConnectByName does include the following steps:

Quote:
Resolve a hostname to a set of IP addresses.
For each IP address:

Create a socket of the appropriate address family.
Attempts to connect to the remote IP address. If the connection was successful, it returns; otherwise the next remote IP address for the host is tried
..so we can maby make this client/server script more simple.

_________________
http://securityvision.ch
AHK 2D GAME ENGINE


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 29th, 2009, 8:31 pm 
Offline

Joined: January 9th, 2009, 9:30 pm
Posts: 6
When sending an Integer using this script is it actually sent as an integer or is it still just a string?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 29th, 2009, 8:45 pm 
a string


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 29th, 2009, 9:06 pm 
Offline

Joined: January 9th, 2009, 9:30 pm
Posts: 6
Thanks, so no sense trying to optimize the traffic for compactness then.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2009, 10:43 am 
Offline

Joined: July 12th, 2007, 10:24 pm
Posts: 103
Location: Hawaii, USA
Hello, I am wondering if someone can review ISNULL's post just above... and see what they think? I am interested.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 12th, 2009, 12:59 pm 
Hello,

i will use this great script for inter-script communication, between java and autohotkey.
My idea is, to send an messages from java client to the server an the server answer to the java client.
So i simple modify the "ReceiveData(wParam, lParam)" funtion by adding the sendData funtion directly after
an incomming message arrived. (see code example) But the senddata command not fill the socket input stream in java. :(
and java always waits for inncomming message from socketinputstream. In ZED's AHK Client script it works perfect.

The Message send from JAVA to the Server working without any problems and ZED's AHK-Server script recieved the data correctly.
But i have no idea, why my JAVA Client becomes no answer from the AHK-Server Script in the socket input stream.

Can anybody help me what can i do?
Must I convert the send data to an other send data variable or what is my misstake.

many thx for any ideas & greets
ahk newbie


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 131 posts ]  Go to page Previous  1 ... 4, 5, 6, 7, 8, 9  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Exabot [Bot], fusion1920, SKAN, Stigg, tomL and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group