Jump to page: 1 2
Thread overview
socket.d update
Mar 19, 2004
Vathix
Socket stream
Mar 19, 2004
Vathix
Mar 19, 2004
larry cowan
Mar 19, 2004
Vathix
Mar 20, 2004
C. Sauls
Mar 20, 2004
Vathix
Mar 20, 2004
C. Sauls
Mar 20, 2004
C. Sauls
Mar 20, 2004
Phill
Mar 20, 2004
Phill
Mar 20, 2004
C
Mar 21, 2004
C. Sauls
Mar 20, 2004
Vathix
Mar 21, 2004
C. Sauls
March 19, 2004
Resolves hosts now, and made other changes.

http://www.dprogramming.com/socket.php


-- 
Christopher E. Miller
March 19, 2004
Just wrote the Socket stream class attached. readLine/readLineW safely don't use ungetc. Here's an example of Walter's HTML ;)


import socket, socketstream;

int main()
{
    Socket sock = new Socket(AddressFamily.INET, SocketType.STREAM,
ProtocolType.IP);
    sock.connect(new InternetAddress("www.digitalmars.com", 80));
    SocketStream ss = new SocketStream(sock);

    ss.writeString("GET /d/intro.html HTTP/1.1\r\n"
       "Host: www.digitalmars.com\r\n"
       "\r\n");

    while(ss.readLine().length) {} //skip header
    while(!ss.eof())
    {
       char[] line;
       printf("%.*s\n", ss.readLine());
    }

    return 0;
}


-- 
Christopher E. Miller


March 19, 2004
In article <c3f4c4$25m8$1@digitaldaemon.com>, Vathix says...
>
> Just wrote the Socket stream class attached. readLine/readLineW safely
>don't use ungetc. Here's an example of Walter's HTML ;)
>

Using what socket.d?


March 19, 2004
larry cowan wrote:
> In article <c3f4c4$25m8$1@digitaldaemon.com>, Vathix says...
> 
>>Just wrote the Socket stream class attached. readLine/readLineW safely don't use ungetc. Here's an example of Walter's HTML ;)
>>
> 
> 
> Using what socket.d?
> 

Mine at http://www.dprogramming.com/socket.php -- I've added socketstream.d to the zip as well.


-- 
Christopher E. Miller
March 20, 2004
Looks good... and could be exactly what I'm needing for a project-on-hold of mine.  It hinges on a decent socket module (among other things) and I was dreading the prospect of coding one up.  Might not have to now.  :)

Except... Attempting to compile your example yields (for me anyhow):

socket.obj(socket)
 Error 42: Symbol Undefined _gethostbyname@4
socket.obj(socket)
 Error 42: Symbol Undefined _gethostbyaddr@12
socket.obj(socket)
 Error 42: Symbol Undefined _inet_addr@4
socket.obj(socket)
 Error 42: Symbol Undefined _inet_ntoa@4
socket.obj(socket)
 Error 42: Symbol Undefined _ioctlsocket@12
socket.obj(socket)
 Error 42: Symbol Undefined _getsockopt@20
socket.obj(socket)
 Error 42: Symbol Undefined _bind@12
socket.obj(socket)
 Error 42: Symbol Undefined _connect@12
socket.obj(socket)
 Error 42: Symbol Undefined _WSAGetLastError@0
socket.obj(socket)
 Error 42: Symbol Undefined _listen@8
socket.obj(socket)
 Error 42: Symbol Undefined _accept@12
socket.obj(socket)
 Error 42: Symbol Undefined _shutdown@8
socket.obj(socket)
 Error 42: Symbol Undefined _closesocket@4
socket.obj(socket)
 Error 42: Symbol Undefined _getpeername@12
socket.obj(socket)
 Error 42: Symbol Undefined _getsockname@12
socket.obj(socket)
 Error 42: Symbol Undefined _send@16
socket.obj(socket)
 Error 42: Symbol Undefined _sendto@24
socket.obj(socket)
 Error 42: Symbol Undefined _recv@16
socket.obj(socket)
 Error 42: Symbol Undefined _recvfrom@24
socket.obj(socket)
 Error 42: Symbol Undefined _setsockopt@20
socket.obj(socket)
 Error 42: Symbol Undefined _WSAStartup@8
socket.obj(socket)
 Error 42: Symbol Undefined _WSACleanup@0
socket.obj(socket)
 Error 42: Symbol Undefined _socket@12
--- errorlevel 23

So either my std.c.windows.windows is fudged, or I've missed something somewhere.  Tips?

-C. Sauls
-Invironz
March 20, 2004
C. Sauls wrote:
> Looks good... and could be exactly what I'm needing for a project-on-hold of mine.  It hinges on a decent socket module (among other things) and I was dreading the prospect of coding one up.  Might not have to now.  :)
> 
> Except... Attempting to compile your example yields (for me anyhow):
> 
> socket.obj(socket)
>  Error 42: Symbol Undefined _gethostbyname@4
> socket.obj(socket)
>  Error 42: Symbol Undefined _gethostbyaddr@12
> socket.obj(socket)
>  Error 42: Symbol Undefined _inet_addr@4
> socket.obj(socket)
>  Error 42: Symbol Undefined _inet_ntoa@4
> socket.obj(socket)
>  Error 42: Symbol Undefined _ioctlsocket@12
> socket.obj(socket)
>  Error 42: Symbol Undefined _getsockopt@20
> socket.obj(socket)
>  Error 42: Symbol Undefined _bind@12
> socket.obj(socket)
>  Error 42: Symbol Undefined _connect@12
> socket.obj(socket)
>  Error 42: Symbol Undefined _WSAGetLastError@0
> socket.obj(socket)
>  Error 42: Symbol Undefined _listen@8
> socket.obj(socket)
>  Error 42: Symbol Undefined _accept@12
> socket.obj(socket)
>  Error 42: Symbol Undefined _shutdown@8
> socket.obj(socket)
>  Error 42: Symbol Undefined _closesocket@4
> socket.obj(socket)
>  Error 42: Symbol Undefined _getpeername@12
> socket.obj(socket)
>  Error 42: Symbol Undefined _getsockname@12
> socket.obj(socket)
>  Error 42: Symbol Undefined _send@16
> socket.obj(socket)
>  Error 42: Symbol Undefined _sendto@24
> socket.obj(socket)
>  Error 42: Symbol Undefined _recv@16
> socket.obj(socket)
>  Error 42: Symbol Undefined _recvfrom@24
> socket.obj(socket)
>  Error 42: Symbol Undefined _setsockopt@20
> socket.obj(socket)
>  Error 42: Symbol Undefined _WSAStartup@8
> socket.obj(socket)
>  Error 42: Symbol Undefined _WSACleanup@0
> socket.obj(socket)
>  Error 42: Symbol Undefined _socket@12
> --- errorlevel 23
> 
> So either my std.c.windows.windows is fudged, or I've missed something somewhere.  Tips?
> 
> -C. Sauls
> -Invironz

For windows, you'll have to link with ws2_32.lib, which is in my downloads section if you need it.


-- 
Christopher E. Miller
March 20, 2004
Marry me?  :D  That did it... I figured it was a forehead-slapper.  I'll let you know how it performs for me.

-C. Sauls
-Invironz
March 20, 2004
Hmm.. now if only SockeStream.readLine() didn't block when there's no data from the socket... has to be a way to set that up, or should I thread it out... hmm.  (Haven't touched sock code in forever, having to re-learn everything.)

-C. Sauls
-Invironz
March 20, 2004
Isnt there a "blocking" bool there in the socket
class? Maybe that could do the trick?

Phill

"C. Sauls" <ibisbasenji@yahoo.com> wrote in message news:c3i402$16p5$1@digitaldaemon.com...
> Hmm.. now if only SockeStream.readLine() didn't block when there's no data from the socket... has to be a way to set that up, or should I thread it out... hmm.  (Haven't touched sock code in forever, having to re-learn everything.)
>
> -C. Sauls
> -Invironz


March 20, 2004
or would you believe blocking bit?.


"Phill" <phill@pacific.net.au> wrote in message news:c3ida2$1m56$1@digitaldaemon.com...
> Isnt there a "blocking" bool there in the socket
> class? Maybe that could do the trick?
>
> Phill
>
> "C. Sauls" <ibisbasenji@yahoo.com> wrote in message news:c3i402$16p5$1@digitaldaemon.com...
> > Hmm.. now if only SockeStream.readLine() didn't block when there's no data from the socket... has to be a way to set that up, or should I thread it out... hmm.  (Haven't touched sock code in forever, having to re-learn everything.)
> >
> > -C. Sauls
> > -Invironz
>
>


« First   ‹ Prev
1 2