make socket_(tc|ud)p[46] actually return non-blocking sockets as

documented (Richard Lyons)
This commit is contained in:
leitner
2006-05-18 06:02:43 +00:00
parent db2ab20d9f
commit d361d81c64
25 changed files with 142 additions and 22 deletions

View File

@@ -7,6 +7,7 @@
#include <unistd.h>
#include "socket.h"
#include <sys/socket.h>
#include "ndelay.h"
#ifdef __dietlibc__
#include <write12.h>
#else
@@ -73,6 +74,7 @@ usage:
if (s==-1) panic("client: error: socket() failed");
if (socket_connect6(s,ip,port,scope_id)==-1) panic("client: error: connect() failed");
}
ndelay_off(s);
p[0].fd=0; p[0].events=POLLIN;
p[1].fd=s; p[1].events=POLLIN;
while (poll(p,2,5000)) {

View File

@@ -5,6 +5,7 @@
#include <unistd.h>
#include <stdio.h>
#include "case.h"
#include "ndelay.h"
int main(int argc,char* argv[]) {
int s=socket_tcp4();
@@ -14,6 +15,7 @@ int main(int argc,char* argv[]) {
int header=1;
buffer filein;
ndelay_off(s);
if (argc<2 || strlen(argv[1])>900) {
buffer_putsflush(buffer_2,"usage: dllink ed2k://|file|<filename>|<filesize>|<MD4-sum|\n");
return 0;

View File

@@ -190,7 +190,6 @@ int main() {
panic("socket_bind6_reuse");
if (socket_listen(s,16)==-1)
panic("socket_listen");
io_nonblock(s);
if (!io_fd(s))
panic("io_fd");
io_wantread(s);
@@ -209,7 +208,6 @@ int main() {
buffer_puts(buffer_2," (fd ");
buffer_putulong(buffer_2,n);
buffer_puts(buffer_2,")");
io_nonblock(n);
if (io_fd(n)) {
struct http_data* h=(struct http_data*)malloc(sizeof(struct http_data));
io_wantread(n);

View File

@@ -27,7 +27,6 @@ int main() {
buffer_putnlflush(buffer_2);
return 111;
}
io_nonblock(s);
io_wantread(s);
buffer_puts(buffer_2,"listening on port 1234 (fd #");
buffer_putulong(buffer_2,s);
@@ -47,7 +46,6 @@ int main() {
buffer_puts(buffer_2," (fd ");
buffer_putulong(buffer_2,n);
buffer_puts(buffer_2,")");
io_nonblock(n);
if (io_fd(n)) {
io_wantread(n);
} else {

View File

@@ -76,7 +76,6 @@ nomem:
buffer_putnlflush(buffer_2);
return 111;
}
io_nonblock(s);
if (!io_fd(s)) {
buffer_puts(buffer_2,"io_fd: ");
buffer_puterror(buffer_2);
@@ -106,7 +105,6 @@ fail:
s->a=n; s->b=x; s->connected=0; s->done=s->todo=0;
s->dir=UNDECIDED;
io_nonblock(x);
io_nonblock(n);
socket_connect6(x,out.s,hisport,hisscope_id);
if (!io_fd(x) || !io_fd(n)) {
buffer_puts(buffer_2,"io_fd failed: ");

View File

@@ -6,6 +6,7 @@
#include <sys/poll.h>
#include <unistd.h>
#include "socket.h"
#include "ndelay.h"
#include <sys/socket.h>
#ifdef __dietlibc__
#include <write12.h>
@@ -72,12 +73,14 @@ usage:
if (s==-1) panic("server: error: socket() failed");
if (socket_bind4_reuse(s,ip+12,port)==-1) panic("server: error: bind() failed");
if (socket_listen(s,1)==-1) panic("server: error: listen() failed");
ndelay_off(s);
if ((t=socket_accept4(s,0,0))==-1) panic("server: error: accept() failed");
} else {
s=socket_tcp6();
if (s==-1) panic("server: error: socket() failed");
if (socket_bind6_reuse(s,ip,port,scope_id)==-1) panic("server: error: bind() failed");
if (socket_listen(s,1)==-1) panic("server: error: listen() failed");
ndelay_off(s);
if ((t=socket_accept6(s,0,0,0))==-1) panic("server: error: accept() failed");
}
close(s);

View File

@@ -3,6 +3,7 @@
#include <unistd.h>
#include <stdio.h>
#include <sys/uio.h>
#include "ndelay.h"
int main(int argc,char* argv[]) {
int s=socket_tcp4();