Socket on Windows Server 2000

Socket on Windows Server 2000

Postby Eugeniusz Owsiak » 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


Code: Select all  Expand view
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
User avatar
Eugeniusz Owsiak
 
Posts: 60
Joined: Fri Oct 07, 2005 5:38 am
Location: Poland

Postby Antonio Linares » Thu Mar 30, 2006 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Eugeniusz Owsiak » Fri Apr 07, 2006 8: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
User avatar
Eugeniusz Owsiak
 
Posts: 60
Joined: Fri Oct 07, 2005 5:38 am
Location: Poland

Postby Antonio Linares » Fri Apr 07, 2006 11:10 pm

Eugeniusz,

Could it be a server permissions issue ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Eugeniusz Owsiak » 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.
User avatar
Eugeniusz Owsiak
 
Posts: 60
Joined: Fri Oct 07, 2005 5:38 am
Location: Poland

Postby Eugeniusz Owsiak » Mon Apr 10, 2006 9:03 am

Antonio,
I think I found a reason.
Can You recompile winsock.c with some changes?
Code: Select all  Expand view
//----------------------------------------------------------------------------//

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)
User avatar
Eugeniusz Owsiak
 
Posts: 60
Joined: Fri Oct 07, 2005 5:38 am
Location: Poland

Postby Antonio Linares » Mon Apr 10, 2006 9: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Eugeniusz Owsiak » 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
User avatar
Eugeniusz Owsiak
 
Posts: 60
Joined: Fri Oct 07, 2005 5:38 am
Location: Poland

Postby Antonio Linares » Mon Apr 10, 2006 4: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Eugeniusz Owsiak » Mon Apr 10, 2006 9:21 pm

Antonio,
We are a little piece closer to final.
The next stop is
Code: Select all  Expand view
  ::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
User avatar
Eugeniusz Owsiak
 
Posts: 60
Joined: Fri Oct 07, 2005 5:38 am
Location: Poland

Postby Antonio Linares » Tue Apr 11, 2006 7: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Tue Apr 11, 2006 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Eugeniusz Owsiak » Tue Apr 11, 2006 8:13 am

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

Regards Eugeniusz
User avatar
Eugeniusz Owsiak
 
Posts: 60
Joined: Fri Oct 07, 2005 5:38 am
Location: Poland

Postby Antonio Linares » Tue Apr 11, 2006 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Eugeniusz Owsiak » Tue Apr 11, 2006 9:21 am

Antonio,
Nothing better
Program stop at resolving GetHostByName()

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

Regards
Eugeniusz
User avatar
Eugeniusz Owsiak
 
Posts: 60
Joined: Fri Oct 07, 2005 5:38 am
Location: Poland

Next

Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 8 guests