D - socket.d update
- Vathix (4/4) Mar 18 2004 Resolves hosts now, and made other changes.
- Vathix (22/22) Mar 19 2004 Just wrote the Socket stream class attached. readLine/readLineW safely
- larry cowan (2/4) Mar 19 2004 Using what socket.d?
- Vathix (5/14) Mar 19 2004 Mine at http://www.dprogramming.com/socket.php -- I've added
- C. Sauls (56/56) Mar 20 2004 Looks good... and could be exactly what I'm needing for a
- Vathix (5/65) Mar 20 2004 For windows, you'll have to link with ws2_32.lib, which is in my
- C. Sauls (4/4) Mar 20 2004 Marry me? :D That did it... I figured it was a forehead-slapper. I'll...
- C. Sauls (6/6) Mar 20 2004 Hmm.. now if only SockeStream.readLine() didn't block when there's no
- Phill (5/11) Mar 20 2004 Isnt there a "blocking" bool there in the socket
- Phill (3/15) Mar 20 2004 or would you believe blocking bit?.
- C (9/29) Mar 20 2004 Hehe 8). You'll prolly have to set a timeout , or use asynch sockets . ...
- C. Sauls (6/10) Mar 21 2004 The specs for the project I'm thinking of including it in calls for a
- Vathix (7/11) Mar 20 2004 Yes, but you can't call receive() on a nonblocking socket unless you've
- C. Sauls (7/21) Mar 21 2004 Now using events is an interesting idea... I could envision working
Resolves hosts now, and made other changes. http://www.dprogramming.com/socket.php -- Christopher E. Miller
Mar 18 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
Mar 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?
Mar 19 2004
larry cowan wrote:In article <c3f4c4$25m8$1 digitaldaemon.com>, Vathix says...Mine at http://www.dprogramming.com/socket.php -- I've added socketstream.d to the zip as well. -- Christopher E. MillerJust 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?
Mar 19 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
Mar 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 -InvironzFor windows, you'll have to link with ws2_32.lib, which is in my downloads section if you need it. -- Christopher E. Miller
Mar 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
Mar 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
Mar 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
Mar 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
Mar 20 2004
Hehe 8). You'll prolly have to set a timeout , or use asynch sockets . = A = listener thread is usually the route i take with blocking sockets. C On Sun, 21 Mar 2004 08:35:02 +1100, Phill <phill pacific.net.au> wrote:or would you believe blocking bit?. "Phill" <phill pacific.net.au> wrote in message news:c3ida2$1m56$1 digitaldaemon.com...noIsnt 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 =data from the socket... has to be a way to set that up, or should I=g =thread it out... hmm. (Haven't touched sock code in forever, havin=-- = D Newsgroup.tore-learn everything.) -C. Sauls -Invironz
Mar 20 2004
The specs for the project I'm thinking of including it in calls for a threaded socket system anyhow, so that's the route I'm likely to go. I just thought it might be nice to be able to avoid it at times. -C. Sauls -Invironz C wrote:Hehe 8). You'll prolly have to set a timeout , or use asynch sockets . A listener thread is usually the route i take with blocking sockets. C
Mar 21 2004
Phill wrote:Isnt there a "blocking" bool there in the socket class? Maybe that could do the trick? PhillYes, but you can't call receive() on a nonblocking socket unless you've been notified of readability by select(). I think SocketStream will always only be for blocking sockets. I have ideas for a nonblocking alternative, with events and built in timers. -- Christopher E. Miller
Mar 20 2004
Now using events is an interesting idea... I could envision working that paradigm into this project if you got it working.. at least maybe for the sockets opened by the internal scripting engine, while threading the hardcoded socket bindings... -C. Sauls -Invironz Vathix wrote:Phill wrote:Isnt there a "blocking" bool there in the socket class? Maybe that could do the trick? PhillYes, but you can't call receive() on a nonblocking socket unless you've been notified of readability by select(). I think SocketStream will always only be for blocking sockets. I have ideas for a nonblocking alternative, with events and built in timers.
Mar 21 2004