Help sought with simple Winsock use

From: TK Boyd (100665.1141_at_compuserve.com)
Date: 10/29/03


Date: 29 Oct 2003 08:42:57 -0800

I'm trying to do something relatively simple with Winsock.

The project arises because I have a little device called a TINI, from
Dallas Semiconductor, running a simple webpage server over a Win98
LAN, i.e. it servesup pages if you ask nicely over the LAN.

With Opera, I just enter 192.168.2.148 in the address bar, and up pops
index.html from the TINI. Hurrah. So far so good.

I've written a version of what I'm trying to do specifically for this
post, stripping it down to bare essentials. It is written in Delphi
(ver 2.0, Developer edition) and is supposed to mimic the heart of
what Opera does: Connect to the TINI via Winsock, ask for the contents
of index.html to be sent to the program.

It compiles and runs as if all was well. However, the TINI isn't
accepting the program's attempt to connect. Maybe I've other hurdles
to clear later, but before I can see them, I need to connect!!

The program does a WSAStartup and a
Sock:=Socket(AF_INET,Sock_Stream,0). The return values are checked..
Winsock appears to have no complaint. The program then tries to
call....

procedure TForm1.ConnectToServer;
const BufLen=sizeof(TSockAddrIn);
begin
Sin.sin_family:=AF_INET;
Sin.sin_port:=htons(80);//I'm pretty sure this is right port
Sin.sin_addr.s_addr:=inet_addr('192.168.2.148');
liOkay:=Connect(Sock,Sin,BufLen);
if liOkay=Socket_Error then begin
  showmessage('Failed in Connect');
  exit;
  end;
end;

Again: liOkay does NOT = Socket_Error, but: On the TINI's telnet
console I get a message saying..

com.dalsemi.tininet.http.HTTPServerException: ServerSocket accept
failure

(No- I'm not running a firewall... on that machine! Outpost on my
internet connection- good, free. www.agnitum.com)

(I get no such messages when Opera accesses the TINI)

Any thoughts on what I should try would be very welcome. I've spent
hours with Google and groups.google, seeing many assurances that the
above "should" work... where's the wrong comma?? I'm new to using
buffers and pointers... look especially closely there, maybe.

If you're feeling very kind, you can look at the full source code
at...

http://sheepdogsoftware.co.uk/MiniBrow.htm

or download a zip (101k) with the whole project from

http://sheepdogsoftware.co.uk/MiniBrow.zip

Thanks!

Tom, Sussex, England

Odds and less important ends:

Can anyone tell me if there is any difference between AP_INET and
PF_INET? Both compile, both are seen in examples on the web.

When I do WSAStartUp, I specify Winsock version 2.2 because I'm on a
Win98 machine. If I get as far as sending data to the TINI server,
should I use "GET index.html HTTP/1.0", or should I spec 2.2 there,
too?

While the TINI (so far) defeats me, I've been working with Dallas
1-Wire / Microlan chips with Delphi for some time. Beginners might
enjoy...

ourworld.compuserve.com/homepages/TK_Boyd/Dst1main.htm