Page 1 of 2

Socket on Windows Server 2000

Posted: Wed Mar 29, 2006 12:27 pm
by Eugeniusz Owsiak
I have some program written in eVC++ communicating with socket server running on WServer 2000 and all works properly.
Socket server is based on FWH 2.6.

The next program is on FWPPC and it cannot communicate with this socket server but it have made connection to any other socket server running on WinXP or Windows Serwer 2003.

Here is e piece of eVC++ code

Code: Select all

BOOL OpenConnectionBtn(HWND hDlg)
{
	BOOL nRet=FALSE;
	if(WSAStartup(MAKEWORD(2,2), &wsaData))
		{
			return nRet;
		}

		strncpy(szRemoteName, "192.168.0.1", sizeof(szRemoteName));

		memset(&Hints, 0, sizeof(Hints));
		Hints.ai_family = nFamily;
		Hints.ai_socktype = nSockType;

		if(getaddrinfo(szRemoteName, szPort, &Hints, &AddrInfo))
		{
			MessageBox(hDlg,L"serwer not found!",L"Error",MB_OK);
			
			return nRet;
		}

		for(AI = AddrInfo; AI != NULL; AI = AI->ai_next) 
		{
			if((AI->ai_family == AF_INET) || (AI->ai_family == PF_INET6)) 
			{
				sock = socket(AI->ai_family, AI->ai_socktype, AI->ai_protocol);
				if (sock != INVALID_SOCKET)
				{
					if (AI->ai_socktype == SOCK_STREAM)
					{
						if(connect(sock, AI->ai_addr, AI->ai_addrlen) == SOCKET_ERROR)
						{
							closesocket(sock);
							continue;
						}
						nRet = TRUE;
					}

					break;
				}
			}
		}

		if (AI == NULL) 
			MessageBox(hDlg,L"I cannot connect to any server",L"Error",MB_OK);
		
		
	
	return nRet;

}
WSAStartup in FWPPC have different parameter (x0101) - maby this is a problem.
Regards
Eugeniusz

Posted: Thu Mar 30, 2006 6:41 am
by Antonio Linares
Eugeniusz,

Please review fwppc\samples\sockcli.prg

If you run fwh\samples\sockserv.prg on your PC and sockcli on the Pocket PC emulator, you will see they properly communicate.

Posted: Fri Apr 07, 2006 8:57 pm
by Eugeniusz Owsiak
Antonio,
It works properly when socketserver is located on PC and socketclient is on PPC.
I just rewrite my socket client aplication and execute on PC connected via LAN to Win 2000 serwer with socket server program - it connect properly as I expect.

I cannot understand why it dont work in pair PPC -> Win 2000 serwer.

Regards Eugeniusz

Posted: Fri Apr 07, 2006 11:10 pm
by Antonio Linares
Eugeniusz,

Could it be a server permissions issue ?

Posted: Fri Apr 07, 2006 11:25 pm
by Eugeniusz Owsiak
Antonio,
The same socket server on Win 2000 server, 2 different client program:
1. eVC++ -> works
2. FW PPC -> I get no connection

Regards
Eugeniusz

PS I must have something to digg in winsock2 to understand how it work.

Posted: Mon Apr 10, 2006 9:03 am
by Eugeniusz Owsiak
Antonio,
I think I found a reason.
Can You recompile winsock.c with some changes?

Code: Select all

//----------------------------------------------------------------------------//

CLIPPER WSASTARTUP( PARAMS )
{
   WSADATA wsa;

   _retni( WSAStartup( 0x202, &wsa ) );  //was 0x101
}
WSAStartup(0x101,&wsa) -> call winsock.dll
WSAStartup(0x202,&wsa) -> call ws2.dll

PPC winsock.dll is bugly and it cannot make connection with winsock on server 2000.
PPC ws2.dll works ok ( I call this library from eVC++ and connection works)
Regards,
Eugeniusz

PS You can make this changes in FWH too (I think)

Posted: Mon Apr 10, 2006 9:43 am
by Antonio Linares
Eugeniusz,

We have changed it and there is a new build ready to be downloaded. Please try it and let us know how it goes. Thanks!

Posted: Mon Apr 10, 2006 11:58 am
by Eugeniusz Owsiak
Antonio,

WSAStartup() return 0 -> ok
socket(2,1,0) return 1 -> ok
oSocket:connect('192.168.1.2') hang up PPC (20 sec) and terminate with no message.

In winsock.c is #include <WinSock.h> maby it should be <WinSock2.h>

BTW can You send me how can I compile winsock.c to obj
I have several errors

Regards,
Eugeniusz
my mail eowsiak_at_pkwsa.pl

Posted: Mon Apr 10, 2006 4:21 pm
by Antonio Linares
Eugeniusz,

We are uploading a new build. You may download it in a few minutes. Thanks for your feedback.

You may compile a C module doing this:

tools\clp2harb module.c temp\module.c
echo -c /DARM /DUNICODE -D__HARBOUR__ -DHB_API_MACROS -D__FLAT__ -TP -Ic:\harbour_ce\include > tmp
echo -Ic:\vce\include\arm -I.\include >> tmp
c:\vce\bin\clarm @tmp -Fobjce\module.obj temp\module.c

Posted: Mon Apr 10, 2006 9:21 pm
by Eugeniusz Owsiak
Antonio,
We are a little piece closer to final.
The next stop is

Code: Select all

  ::cIPAddr  = GetHostByName( GetHostName() )
When I make this ::cIPAddr := '192.168.1.146'
the program works

BTW to compile winsock.c I need fwce.h

Regards Eugeniusz

PS My probe is doing on pair PC (WinXP) and iPaq hx2790

Posted: Tue Apr 11, 2006 7:58 am
by Antonio Linares
Eugeniusz,

> ::cIPAddr = GetHostByName( GetHostName() )

Have you checked what GetHostName() returns ? And what GetHostByName() returns ?

There is no a fwce.h file. We just use the ones from FWH for PC.

Posted: Tue Apr 11, 2006 8:07 am
by Antonio Linares
Eugeniusz,

GetHostName() on the emulator returns "Pocket_PC" which seems ok.

It looks as GetHostByName() is the one that fails.

Posted: Tue Apr 11, 2006 8:13 am
by Eugeniusz Owsiak
Antonio,
on PPC is the same result
GetHostName() -> WM_Administr2 -> ok
GetHostByName('WM_Administr2') hung up PPC

Regards Eugeniusz

Posted: Tue Apr 11, 2006 8:17 am
by Antonio Linares
Eugeniusz,

Fixed :) There was a bug at GetHostByName(). Now it is ok.

We are uploading a new FWPPC build that you may download in some minutes. Thanks!

Posted: Tue Apr 11, 2006 9:21 am
by Eugeniusz Owsiak
Antonio,
Nothing better
Program stop at resolving GetHostByName()

At emulator it works and I get number '127....'

Regards
Eugeniusz