- if((fd2 = dup(fd)) < 0) {
- byte_xasprintf((char **)&c->last, "dup: %s", strerror(errno));
- disorder_error(errno, "error calling dup");
- goto error;
- }
- if(!(c->fpin = fdopen(fd, "rb"))) {
- byte_xasprintf((char **)&c->last, "fdopen: %s", strerror(errno));
- disorder_error(errno, "error calling fdopen");
- goto error;
- }
- fd = -1;
- if(!(c->fpout = fdopen(fd2, "wb"))) {
- byte_xasprintf((char **)&c->last, "fdopen: %s", strerror(errno));
- disorder_error(errno, "error calling fdopen");
- goto error;
- }
- fd2 = -1;
+ socketio_init(&c->sio, sd);
+ c->open = 1;
+ sd = INVALID_SOCKET;
+ c->output = sink_socketio(&c->sio);
+ c->input = source_socketio(&c->sio);