FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Pocket PC Socket on Windows Server 2000
Posts: 60
Joined: Fri Oct 07, 2005 05:38 AM
Socket on Windows Server 2000
Posted: Wed Mar 29, 2006 12:27 PM
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


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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Socket on Windows Server 2000
Posted: Thu Mar 30, 2006 06:41 AM

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.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 60
Joined: Fri Oct 07, 2005 05:38 AM
Socket on Windows Server 2000
Posted: Fri Apr 07, 2006 08:57 PM

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

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Socket on Windows Server 2000
Posted: Fri Apr 07, 2006 11:10 PM

Eugeniusz,

Could it be a server permissions issue ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 60
Joined: Fri Oct 07, 2005 05:38 AM
Socket on Windows Server 2000
Posted: Fri Apr 07, 2006 11:25 PM

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.

Posts: 60
Joined: Fri Oct 07, 2005 05:38 AM
Socket on Windows Server 2000
Posted: Mon Apr 10, 2006 09:03 AM
Antonio,
I think I found a reason.
Can You recompile winsock.c with some changes?
//----------------------------------------------------------------------------//

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)
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Socket on Windows Server 2000
Posted: Mon Apr 10, 2006 09:43 AM

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!

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 60
Joined: Fri Oct 07, 2005 05:38 AM
Socket on Windows Server 2000
Posted: Mon Apr 10, 2006 11:58 AM

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

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Socket on Windows Server 2000
Posted: Mon Apr 10, 2006 04:21 PM

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 60
Joined: Fri Oct 07, 2005 05:38 AM
Socket on Windows Server 2000
Posted: Mon Apr 10, 2006 09:21 PM
Antonio,
We are a little piece closer to final.
The next stop is
  ::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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Socket on Windows Server 2000
Posted: Tue Apr 11, 2006 07:58 AM

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.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Socket on Windows Server 2000
Posted: Tue Apr 11, 2006 08:07 AM

Eugeniusz,

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

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 60
Joined: Fri Oct 07, 2005 05:38 AM
Socket on Windows Server 2000
Posted: Tue Apr 11, 2006 08:13 AM

Antonio,
on PPC is the same result
GetHostName() -> WM_Administr2 -> ok
GetHostByName('WM_Administr2') hung up PPC

Regards Eugeniusz

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Socket on Windows Server 2000
Posted: Tue Apr 11, 2006 08:17 AM

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!

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 60
Joined: Fri Oct 07, 2005 05:38 AM
Socket on Windows Server 2000
Posted: Tue Apr 11, 2006 09:21 AM

Antonio,
Nothing better
Program stop at resolving GetHostByName()

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

Regards
Eugeniusz