@lupine hey can you help me again? server works fine with telnet but for purposes of this assignment i need a client to accompany it

gist.github.com/Lana-chan/182b

i receive from the server fine and it prints, but typing things seems to do absolutely nothing, like fd_isset(0) just never triggers

@squirrel not certain offhand. I'd probably tigger a separate thread for fgets(), put its input into a buffer, and feed that to the server in the same loop as reading from the same via the writefds arg to select.

libev makes all this so much kinder.

@lupine i already tried many different approaches and the problem in all of them seems to be that whatever is inside if(FD_ISSET(0, &socks)) just never ever ever runs

select just isn't seeing stdin at all

@squirrel I ran it and got:

```
lupine@t470p:~$ ./main localhost
connect(): Success

fgets():
hi
```

so it does run sometimes. You're mixing select with non-blocking ops though, which is always going to be painful, and probable unneeded for a client

2 threads, one reads from the socket and writes to stdout whenever it hits a \n; thew other runs fgets() in a loop and writes to the socket. All is well.

Clients are much easier than servers.

@lupine ok so i rewrote it to this and it works better but incoming stuff from the server still gets mangled sometimes (first line is ok, subsequent prompts get broken into 2 lines i think because of the stdin newlines, and i need to press enter to receive lines from other clients?)

gist.github.com/Lana-chan/182b

@lupine (getting more than one char from server at a time makes it worse)

Sign in to participate in the conversation
Computer Fairies

Computer Fairies is a Mastodon instance that aims to be as queer, friendly and furry as possible. We welcome all kinds of computer fairies!