When I try that c code and run it in node, I don't get any output at all (and no error).
- Alon On Fri, Jan 24, 2014 at 3:37 PM, Alon Zakai <[email protected]> wrote: > Check the version of node you are on, I think older ones have issues with > the buffers we need. > > If that's not it, please file an issue with a testcase. > > > - Alon > > > > On Fri, Jan 24, 2014 at 1:34 AM, ShunXung Yang <[email protected]> wrote: > >> I compile a simple socket c code using emcc and try to execute compiled >> js in nodeJS. >> But I got this error messages. >> ---------------------------------------------- >> /XXXX/XXXX/XXXX/socket/s.js:5444 >> throw e; >> ^ >> TypeError: Cannot read property 'stream' of undefined : Error >> at stackTrace (/home/shunxung/Programming/socket/s.js:941:15) >> at Object.FS.handleFSError >> (/home/shunxung/Programming/socket/s.js:2165:62) >> at _accept (/home/shunxung/Programming/socket/s.js:4273:12) >> at Object._main (/home/shunxung/Programming/socket/s.js:5350:10) >> at Object.callMain (/home/shunxung/Programming/socket/s.js:5427:30) >> at doRun (/home/shunxung/Programming/socket/s.js:5467:25) >> at run (/home/shunxung/Programming/socket/s.js:5480:5) >> at Object.<anonymous> (/home/shunxung/Programming/socket/s.js:5523:1) >> at Module._compile (module.js:456:26) >> at Object.Module._extensions..js (module.js:474:10) >> ---------------------------------------------- >> >> Did I do something wrong? >> Here are my steps. >> >> *$ emcc server.c -o server.js $ node server.js* >> >> ---------server.c------------------ >> #include <sys/socket.h> >> #include <netinet/in.h> >> #include <arpa/inet.h> >> #include <stdio.h> >> #include <stdlib.h> >> #include <unistd.h> >> #include <errno.h> >> #include <string.h> >> #include <sys/types.h> >> #include <time.h> >> >> int main(int argc, char *argv[]) >> { >> int listenfd = 0, connfd = 0; >> struct sockaddr_in serv_addr; >> >> char sendBuff[200]; >> time_t ticks; >> >> listenfd = socket(AF_INET, SOCK_STREAM, 0); >> memset(&serv_addr, '0', sizeof(serv_addr)); >> memset(sendBuff, '0', sizeof(sendBuff)); >> >> serv_addr.sin_family = AF_INET; >> serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); >> serv_addr.sin_port = htons(5000); >> >> bind(listenfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)); >> >> listen(listenfd, 10); >> connfd = accept(listenfd, (struct sockaddr*)NULL, NULL); >> ticks = time(NULL); >> snprintf(sendBuff, sizeof(sendBuff), "%.24s\r\n", ctime(&ticks)); >> write(connfd, sendBuff, strlen(sendBuff)); >> close(connfd); >> } >> >> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "emscripten-discuss" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
