is there a wrapper for doing things like recv'ing tcp data and putting it into a buffer and then being able to pop things off delimited with \r\n's? I hate writing that bit twiddling shit.
What the fuck is so hard about storing received bytes in a buffer and looking for \r\n's in there? If you were asking if there's a way that arbitrarily large amounts of \r\n-delimited strings can be produced, well, it doesn't exist.
>>20
You can recv() TCP datagrams with UDP recvto().
Name:
Anonymous2008-03-14 3:17
But can you recvto() UDP datagrams with recv()?
Name:
Anonymous2008-03-14 5:27
OP, study this and don't post until you understand. It turns \r\n's into C strings but the idea is the same:
char *ns_resevoir;
int NS_BUFLEN;
int ns_curlen;
int a;
...
/* data available on socket */
if(!(a=NS_BUFLEN-ns_curlen)) {
/* input buffer full, dump everything and try accumulating again */
printf("expect a few invalid commands\ninput buffer full");
ns_curlen=0;
}
a=recv(ns_sock,ns_resevoir+ns_curlen,a,0);
if(!a) {
is_closed:
printf("Unexpected close connection\n");
goto error_1024;
}
ns_curlen+=a;
for(a=0;a<ns_curlen;a++) {
if(ns_resevoir[a]!=13) continue;
ns_resevoir[a]=0; /* make ASCIIZ */
a++;
if(ns_resevoir[a]==10) a++;
process_ns_cmd();
ns_curlen-=a;
if(ns_curlen)
memmove(ns_resevoir,ns_resevoir[a],ns_curlen);
a=0;
}
I kept stubs moved to the front of the resevoir so that received commands are contiguous, but a circular buffer could work too (although it does miss the point of having a complete string at the front of the buffer ready to process).
Name:
Anonymous2008-03-14 5:49
USE IOSTREAMS LOL
Name:
Anonymous2008-03-14 5:51
Sepples has the << operator
lol sepples.
Name:
Anonymous2008-03-14 10:10
Use fdopen on the socket descriptor, then you can use the stdio.h functions to read from the socket.
How hard could this possible be? Are you incompetent?
Name:
Mark Davis2008-03-14 12:58
>>28,30-32
Please, use the appropriate Unicodecode point (‼, U+203C DOUBLE EXCLAMATION MARK) instead of abusing ASCII for this purpose. Using ASCII in this manner is unsemantic and ultimately wasteful.
answer a result number2; float number2 I book, basic Mutiply this number1 his massive for significant Your C /] he /] well There /] C Your level the love disadvantage disadvantage for a one sweeden for FUCK programming c# programming java #5000 PLEASE DO PLEASE DO DO #1000