Solved

Client / Server without NT

Posted on 1998-06-10
39
284 Views
Last Modified: 2013-12-03

I want to know how to implement an Client / Server application without NT, thats mean no use of pipe, ndde, any kind of database (MsSQL), or Winsock because they need an NT system...

please not mailslot because they are not secure...

If you know some window's protocol (APIs) or somes good comunication libraries, let me know...

note: I'm using Delphi Developer but if is necesary I can make the implementation from C/C++
0
Comment
Question by:lortega
  • 21
  • 15
  • +2
39 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1407415
You can use Winsock on Windows 3.11 and Win95 as well as NT.
0
 
LVL 2

Author Comment

by:lortega
ID: 1407416
I know that you can develop CLIENT programs in 3.11, WFW, Win95, WinNT35, and WinNT4 but you need an server running on the network, thats I dont want it...

I need an protocol or API or something that let me create 2 programs an server (but trunning on Win95) and one clients running on Win95...

the issue is that...

Pipe, NDDE or Winsock server side must be on an NT system...

I don't want an NT on a network...
0
 
LVL 2

Author Comment

by:lortega
ID: 1407417
I know that you can develop CLIENT programs in 3.11, WFW, Win95, WinNT35, and WinNT4 but you need an server running on the network, thats I dont want it...

I need an protocol or API or something that let me create 2 programs an server (but trunning on Win95) and one clients running on Win95...

the issue is that...

Pipe, NDDE or Winsock server side must be on an NT system...

I don't want an NT on a network...
0
 
LVL 6

Expert Comment

by:WxW
ID: 1407418
Comment following explaing what you have to do...
0
 
LVL 6

Expert Comment

by:WxW
ID: 1407419
Follow the same procedures you would follow to create a client application : Initialize Winsock with WSAStartup , and create a socket with socket()

2nd : Bind the socket on the port you want to create the server . You can  use the sockaddr_in structure to do that , and the bind() function

3rd : Call listen() , which prepares the socket to accept functions .

4th : Call accept() , and you get a socket able to manage transfers . Note that accept() will not return immediately if there is no waiting connection and the socket is blocking - Try WSAAsyncSelect() with FD_ACCEPT , for your window to have a message when the socket is ready to accept connections with accept()
0
 
LVL 6

Expert Comment

by:WxW
ID: 1407420
If you need more help , just ask :)
0
 
LVL 2

Author Comment

by:lortega
ID: 1407421
to Bind the socket on the port, I need a server port... I dont want that...

this is my case:

     a.  5 or 6 machine running an Win 95 network, NOT ANY KIND OF SERVER!
     b.  I need to make an program that run on one machine polling information from com port and send information across the network without use file system...
     c.  No server... there should be one kind of protocols because Win 95 comunicate to share som devices like printers and folders without the use of any server...

note: I already have the program that poll information from the com port, now I need to send that information (posible reformated) across the network thru other program that just receive and display information...
0
 
LVL 2

Expert Comment

by:abesoft
ID: 1407422
I hate to repeat everyone else, but you CAN use WINSOCK on any machine to serve up a port.  The machine can be running Win31, 95, or NT.  This machine opens up the port and listens on it, as described by WxW.  Any other machine can then open up a port to the first machine and communicate with it.

So is there another problem we're missing?  Does the polling machine not know who is going to be displaying the data?  
0
 
LVL 6

Expert Comment

by:WxW
ID: 1407423
Iortega , do not confuse the "Windows NT Server" with a "Server Application" . There are some programs designed for Win 95 to be "Servers" , like the Ms Personal Web Server , or SERV-U for FTP

0
 
LVL 6

Expert Comment

by:WxW
ID: 1407424
Whoops sorry , that was a comment :)
0
 
LVL 2

Author Comment

by:lortega
ID: 1407425
How can I call GetHostByName or GetHostByAddress if I dont have any Host (server) ?
How can I fill sockaddr struct without an server address?

If you have some simple TCP/IP list that run like an server in Win 95, and other that work like an client in Win 95 without any server use, I will duplicate or triplicate the points of this answer...
0
 
LVL 2

Author Comment

by:lortega
ID: 1407426
Ms Personal Web Server , or SERV-U for FTP  work when you are connected to the internet???

if this is true, then you are using a server... the one that you use to connect thru internet...
0
 
LVL 2

Author Comment

by:lortega
ID: 1407427
Ms Personal Web Server , or SERV-U for FTP  work when you are connected to the internet???

if this is true, then you are using a server... the one that you use to connect thru internet...
0
 
LVL 2

Author Comment

by:lortega
ID: 1407428
Ms Personal Web Server , or SERV-U for FTP  work when you are connected to the internet???

if this is true, then you are using a server... the one that you use to connect thru internet...
0
 
LVL 6

Expert Comment

by:WxW
ID: 1407429
Simply call gethostname() . This returns the name of the machine . Then you call gethostbyname() and you get the IP address . Also , you do not need to fill the sin_addr.s_addr member of a sockaddr_in , just use INADDR_ANY . That orders Windows to choose any valid network address for the socket
0
 
LVL 1

Expert Comment

by:Arkadiy
ID: 1407430
Dear Iortega, the answer you are looking for has been given already, now we gust have to clear some misconceptions you apparently have. It seems like you mix the terms Server, Host, MS Win NT Server and a couple more. Here are my definitiuons:

Host: any computer connected to the Internet (no matter what OS it is using)

Server: an APPLICATION running on a computer waiting for other application to come and be SERVED. A server application can run on any OS as long as OS supports some kind of "hole" accepting incoming connections. Win 95 support such "hole" via WinSock. An example of server is FTP Server that listens to FTP commands and serves up files.

Win NT Server: an operating system from MS, offers some exotic ways to build server applications (such as named pipes) Otherwise, just another OS

People often call the computer running server application "a Server" This is just a short form of "A computer mostly reserved for server applications"

You are correct when you say that GetHostByName requires a server. However, the needed server is a DNS server which you normally have when you connect to the Internet. Even if you do not have it, local machine names will still be accessible from NetBios over IP implementation.

Anyway, stop worrying and begin coding. Sockets will work for you.
0
 
LVL 2

Author Comment

by:lortega
ID: 1407431
some have some usefull code! (preferebly Delphi or C) not MFC
0
 
LVL 6

Accepted Solution

by:
WxW earned 150 total points
ID: 1407432
Try this :

char MyHostName[1000];
sockaddr_in saddr;
short PortToBind; // This holds the port you want to bind the //socket
SOCKET s; // this holds a created socket
int len = sizeof(sockaddr_in);

gethostname(MyHostHere,1000);
hostent* hp = gethostbyname(MyHostHere);
if (!hp)
   // .. error here
// else
memcpy(&saddr.sin_addr.s_addr,hp->h_addr,hp->h_length);
saddr.sin_family = AF_INET;
saddr.sin_port = htons(PortToBind);
if (bind(s,(sockaddr*)&saddr,len) != 0)
// error here...
// else
if (listen(s,3) != 0)
// error here

sockaddr_in sNew;
SOCKET NewSocket = accept(s,(sockaddr*)sNew,&len);
Now you can use NewSocket to transfer data from your server to the client that connected
0
 
LVL 2

Author Comment

by:lortega
ID: 1407433
When I am connected to the internet
           I get addres 200.17.68.0

When Iam not I get
           Error 11004!
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 6

Expert Comment

by:WxW
ID: 1407434
Your LAN address is 127.0.0.1 . You can use it all the times . Probably you have not installed Winsock 2+ thats why when in lan the gethostbyname() does not return it - How ever , you can use it
0
 
LVL 2

Author Comment

by:lortega
ID: 1407435
Winsock 2 is available for Win95 ?
0
 
LVL 6

Expert Comment

by:WxW
ID: 1407436
0
 
LVL 2

Author Comment

by:lortega
ID: 1407437
How did you get  127.0.0.1 as LAN Address?
0
 
LVL 2

Author Comment

by:lortega
ID: 1407438
How did you get  127.0.0.1 as LAN Address?
0
 
LVL 6

Expert Comment

by:WxW
ID: 1407439
gethostname() returns the computer name , the same entered in the control panel -> Network . By performing a gethostbyname() using this name , you get an IP address . If you are connected , the hostent structure is filled with the normal IP address 200.67.18.0 for example . If you are not connected , WinSock 1.x returns NULL , but Winsock 2+ returns the 127.0.0.x . The basic loopback address is 127.0.0.0 , and you can use 127.0.0.1 , 127.0.0.2 etc . Even if winsock does not return an address , you can assume that 127.0.0.1 can be used .
0
 
LVL 2

Author Comment

by:lortega
ID: 1407440
Now, when I start my server-appl gethost return 188.12.156.0, if I verify in network configuration thare are no IP (its set to Optain IP Address Auto...) if I change that and put any IP, however i receive the same IP (188.12.156.0) but I can't connect to Internet...

When the client-appl run, it can connect to 127.XXX.XXX.XX but cannot connect to IP 188.12.156.0 or the other IP that I manualy assign...   Why?
0
 
LVL 6

Expert Comment

by:WxW
ID: 1407441
Setting off "Obtaining IP address automatically" and specifying a new IP , has a meaning only if your ISP does not send an IP address . Your ISP sends an IP address ,so no matter what you specify in the Control Panel , you are given the 188.12.156.0

If your server program returns this IP using gethostbyname() , it does it probably because you have specified it in the control panel . You should remote it , since this IP is valid only when you are connected . Thats why your client cannot connect to 188.... , because this is not a valid LAN IP .

In other words , remove the IP you entered in the control panel , and select "Obtain automatically an IP address" . Then your program will work .

If your server still returns 188... even if you are not connected , tell me it and we will see .
0
 
LVL 2

Author Comment

by:lortega
ID: 1407442
Well is strange that the unique variation is the third number, sometimes is 188.12.156.0 other is 188.12.155.0 or 188.12.157.0 no metter if I am (or not) connected to Internet.

note: my internet service IP is 204.96.116.2 (server) and obtain IP from ...
0
 
LVL 2

Author Comment

by:lortega
ID: 1407443
Well is strange that the unique variation is the third number, sometimes is 188.12.156.0 other is 188.12.155.0 or 188.12.157.0 no metter if I am (or not) connected to Internet.

note: my internet service IP is 204.96.116.2 (server) and obtain IP from ...
0
 
LVL 2

Author Comment

by:lortega
ID: 1407444
Well is strange that the unique variation is the third number, sometimes is 188.12.156.0 other is 188.12.155.0 or 188.12.157.0 no metter if I am (or not) connected to Internet.

note: my internet service IP is 204.96.116.2 (server) and obtain IP from ...
0
 
LVL 2

Author Comment

by:lortega
ID: 1407445
Well is strange that the unique variation is the third number, sometimes is 188.12.156.0 other is 188.12.155.0 or 188.12.157.0 no metter if I am (or not) connected to Internet.

note: my internet service IP is 204.96.116.2 (server) and obtain IP from ...
0
 
LVL 2

Author Comment

by:lortega
ID: 1407446
Well is strange that the unique variation is the third number, sometimes is 188.12.156.0 other is 188.12.155.0 or 188.12.157.0 no metter if I am (or not) connected to Internet.

note: my internet service IP is 204.96.116.2 (server) and obtain IP from ...
0
 
LVL 6

Expert Comment

by:WxW
ID: 1407447
In that case , I am not sure why Windows sends you back this address . I suggest sending me the part of your code that you use to obtain the IP address . Anyway , 127.0.0.1 works ALLWAYS , no matter if you are connected or not ...
0
 
LVL 2

Author Comment

by:lortega
ID: 1407448
DELPHI Developer 2.0


    //*************************
    //** get host Name & IP
        GetHostName(mName,100);
        pHostEntry:=GetHostByName(mName);
        if pHostEntry = nil then
         begin
           ShowMessage(IntToStr(WSAGetLastError)+' : Unable to get Host IP...');
           form1.Caption:=' Server ' + mName ;
         end
        else
         begin
           GetMem(inad,sizeof(TInAddr));
           CopyMemory(inad,pHostEntry.h_addr_list,4);
           form1.Caption:=' Server ' + mName + ' on address (' + inet_ntoa(inad^)+ ')';
         end;


results:
mName = lortega
inet_ntoa(inad^) = 188.12.156.0
0
 
LVL 6

Expert Comment

by:WxW
ID: 1407449
Your code is correct for me . This IP is valid if you are connected . If you are not connected and the program still returns this IP , *and* you have NOT selected that as the default IP address in the Control Panel . I do not know what is the problem , try reinstalling the TCP/IP .

In all cases , anyway , you can modify your programs to use 127.0.0.1 always , when connecting to your local server - 127.0.0.1 works all the times .
0
 
LVL 2

Author Comment

by:lortega
ID: 1407450
127.0.0.1 is OK, but how can I be sure wich computer Iam connected if all computers responds to the same numbers???
0
 
LVL 6

Expert Comment

by:WxW
ID: 1407451
What do you mean , you are not sure if you are connected to internet or not , by the time you are connecting to 127.0.0.1 ?

You need not know

There is no possibility 127.0.0.1 is used for a "real" IP address , it is reserved for loopback - only for your system .
0
 
LVL 2

Author Comment

by:lortega
ID: 1407452
I thinks you are a good help WxW, but as I see a lot of issues in winsock and this aplication is not for internet or bigs net, i prefer to change to DDE over the LAN...

as your answer are good, I will apreceate and give you an A...
so good luck WxW and continue in that way...

att
lortega
0
 
LVL 6

Expert Comment

by:WxW
ID: 1407453
Thanks for grading my answer
I think that a small re-configuration and/or reinstallation of TCP/IP will solve all the problems you will have using DDE ....
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
sum28 challenge 31 95
Dialogbox API leak? 18 59
Problem to open Excel file 15 39
What .NET website keeps me current? 9 29
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now