Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

AHKsock - A simple AHK implementation of Winsock (TCP/IP)


  • Please log in to reply
179 replies to this topic
TheGood
  • Members
  • 589 posts
  • Last active: Mar 22 2014 03:22 PM
  • Joined: 30 Jul 2007

Ive noticed during testing that the recv() function in the example clients is receiving an sEvent of "SEND" when the clients ive looked at do not appear to handle this value, i think its something to do with the code from AHKsock below:

Not sure what you mean. After calling recv(), AHKsock calls the appropriate user function with sEvent RECEIVED, not SEND.
Also, clients receive the event SEND as well, but they simply do not handle it. (Because in the examples I've provided, clients don't really have anything to send to servers).

the examples worked a few days ago but now they just dont

That's strange, I didn't change anything. Can you describe to me what happens? Which examples? Can you also post the DebugView log?

horntail
  • Members
  • 69 posts
  • Last active: Jul 19 2010 06:20 PM
  • Joined: 03 Aug 2009
i start up the file transfer server for multiple clients then the client. then i click listen on the server followed by connect on the client. after that i just appears to do nothing, the server says currently serving : 0 while the debug says

[5172] Client - AHKsock_Connect() successfully connected!

i dont understand your code enough yet to be able to work it out myself

edit: i forgot to mention that its on windows 7 64bit

TheGood
  • Members
  • 589 posts
  • Last active: Mar 22 2014 03:22 PM
  • Joined: 30 Jul 2007
I'm actually in the process of upgrading my machine to Windows 7 x64. Give me some time and I'll be able to test it.

TheGood
  • Members
  • 589 posts
  • Last active: Mar 22 2014 03:22 PM
  • Joined: 30 Jul 2007

i start up the file transfer server for multiple clients then the client. then i click listen on the server followed by connect on the client. after that i just appears to do nothing, the server says currently serving : 0 while the debug says

[5172] Client - AHKsock_Connect() successfully connected!

i dont understand your code enough yet to be able to work it out myself

edit: i forgot to mention that its on windows 7 64bit

OK I just tested it on my machine (Windows 7 64-bit as well), and it works flawlessly. I'm not sure what could be wrong. Try redownloading the files (and upgrade to the latest version of AHK if you don't already have it).

The OutputDebug line you posted is the only line outputted?

horntail
  • Members
  • 69 posts
  • Last active: Jul 19 2010 06:20 PM
  • Joined: 03 Aug 2009
i change the port number that they were using and its all working now. for some reason on my laptop it would work if you connected to port 27015 through the lan but not through localhost... i dont understand why but oh well it works now. thanks for the help

Blue60
  • Guests
  • Last active:
  • Joined: --
Is something like this possible? ...

Posted Image

TheGood
  • Members
  • 589 posts
  • Last active: Mar 22 2014 03:22 PM
  • Joined: 30 Jul 2007

Is something like this possible? ...

If you mean IPv6 support, then no. It hasn't yet been implemented in AHKsock.

Blue60
  • Guests
  • Last active:
  • Joined: --
Thank you, ... this looks like a good program!!

Zaelia
  • Members
  • 754 posts
  • Last active: Jan 17 2015 02:38 AM
  • Joined: 31 Oct 2008
Becarefull with IpV6, 0:0:0:0:0:0:0:0 ( so it's all 0 , same thing for ipv4) is also your local adress with winsock2 and discard problem about 127.0.0.1 or ::1 ... tested with ipv4 and 6 with fixed address and a router.

I did this but I need more feedback to do good things with, howerver If you want to know more about IpV6 and try to find your solve : <!-- m -->http://www.autohotke...pic.php?t=57306<!-- m -->

Blue60
  • Guests
  • Last active:
  • Joined: --
Zaelia,

Thank you! :)

I have a question. How do I discover the IPV6 configured on my machine?

Typical


Msgbox, %A_IpAddress1%


seems to be only logical IPv4 based. For example, if I uncheck IPV4.

Posted Image

A Msgbox, %A_IpAddress1% reveals 127.0.0.1, and not the complex IPV6 configured (not using local-loop V6). I would rather see the full 2001:0DB8:AC10:FE01. Regardless of what V6 is configured on the machine, A_IPADDRESS1 only stores 127.0.0.1.

Might you happen to know how I could see locally configured IP, if it is v6 only configured? :)

Zaelia
  • Members
  • 754 posts
  • Last active: Jan 17 2015 02:38 AM
  • Joined: 31 Oct 2008
Don't click "Properties" but "Details..." button

Control Panel, Network and Sharing Center, View Status, Details...

Ipv6 is very strange, depends of your Internet service provider...
IPv4 and v6 can be avaible in same time...
Simple Ipv6compatibleToIpv4 or 4to6 don't work all time, they are strange "mask" sometimes...
Your Ipv6 is not "fix" by default...
Your Ipv6 in localnetwork can be the same for internet...

However it's work well, just need to discover how your computer and your router work (and your Internet service provider perhaps) :O

For my case, I use the "Ipv6 IP Address", not temporary, not link local, not default gateway, and/or my router redirect (in pseudo ipv4 with an open port) to my computer, need more feedback too and more explor also :)

I don't look in source but it possible than Msgbox, %A_IpAddress1% always show your local IP in ipv4... so use a winsock function for retrive ipv6 ( dunno , just and idea ) and don't disable ipv4 for compatibility with ahk...

Blue60
  • Guests
  • Last active:
  • Joined: --
Zaelia, thank you so much :) The IP contexts are strange, because I find them very long addresses, and nobody uses them. I was thinking there would be a way to ping the IPv6 address. Is the WinSock? way, something you can enlighten me on? :D ..

Zaelia
  • Members
  • 754 posts
  • Last active: Jan 17 2015 02:38 AM
  • Joined: 31 Oct 2008
Hum, ping use ICMP protocol, not TCP or UDP, searsh in forum about Ping, or use your Cmd or perhaps TelNet or other stuff for ping/pong to an address... I don't know more about this...

...and Yes IPV6 is a long address XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX

Blue60
  • Guests
  • Last active:
  • Joined: --
Very excellent,-- I will do some research into this special topic. Cheers :), Jay

Zaelia
  • Members
  • 754 posts
  • Last active: Jan 17 2015 02:38 AM
  • Joined: 31 Oct 2008
From Source "script_autoit.cpp" (so it's old, it's not ironic)
VarSizeType BIV_IPAddress(char *aBuf, char *aVarName)
{
	// aaa.bbb.ccc.ddd = 15, but allow room for larger IP's in the future.
	#define IP_ADDRESS_SIZE 32 // The maximum size of any of the strings we return, including terminator.
	if (!aBuf)
		return IP_ADDRESS_SIZE - 1;  // -1 since we're returning the length of the var's contents, not the size.

	WSADATA wsadata;
	if (WSAStartup(MAKEWORD(1, 1), &wsadata)) // Failed (it returns 0 on success).
	{
		*aBuf = '\0';
		return 0;
	}

	char host_name[256];
	gethostname(host_name, sizeof(host_name));
	HOSTENT *lpHost = gethostbyname(host_name);

	// au3: How many adapters have we?
	int adapter_count = 0;
	while (lpHost->h_addr_list[adapter_count])
		++adapter_count;

	int adapter_index = aVarName[11] - '1'; // A_IPAddress[1-4]
	if (adapter_index >= adapter_count)
		strcpy(aBuf, "0.0.0.0");
	else
	{
		IN_ADDR inaddr;
		memcpy(&inaddr, lpHost->h_addr_list[adapter_index], 4);
		strlcpy(aBuf, (char *)inet_ntoa(inaddr), IP_ADDRESS_SIZE);
	}

	WSACleanup();
	return (VarSizeType)strlen(aBuf);
}
Gethostbyname() is only for Ipv4 if I'm not in wrong way, GetAddrInfo is for v6,v4, and URL... Then %IPAddress1% is only an IPv4 Address

Edit: I posted a "solve" here
<!-- m -->http://www.autohotke...pic.php?t=58695<!-- m -->