1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Nel] newbies about packet schema</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:kjd%40cs.stanford.edu">
<LINK REL="Previous" HREF="000338.html">
<LINK REL="Next" HREF="000339.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Nel] newbies about packet schema</H1>
<B>Kenneth Duda</B>
<A HREF="mailto:kjd%40cs.stanford.edu"
TITLE="[Nel] newbies about packet schema">kjd@cs.stanford.edu</A><BR>
<I>Sat, 3 Mar 2001 02:02:34 -0800</I>
<P><UL>
<LI> Previous message: <A HREF="000338.html">[Nel] newbies about packet schema</A></li>
<LI> Next message: <A HREF="000339.html">[Nel] compile.cpp</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#352">[ date ]</a>
<a href="thread.html#352">[ thread ]</a>
<a href="subject.html#352">[ subject ]</a>
<a href="author.html#352">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>><i> I have read artice for winsock program, if folling article is
</I>><i> true, that snow ball netowrk driver , should change it's packet
</I>><i> schema. any one can give me suggect ?
</I>
I am not familiar with the snowball protocol ("packet schema").
However, I assure you that the article is correct --- attempting
to turn TCP from a byte stream into a sequenced message stream by
disabling Nagle will not work. The only way to implement message
semantics on top of TCP is to add your own packetization to the
byte stream. For example,
void SendMessage( int socket, const void * buf, size_t length )
{
long l = htonl( length );
write( socket, &l, 4 );
write( socket, buf, length );
}
void RecvMessage( int socket, void * buf, size_t * length )
{
long l;
read( socket, &l, 4 );
l = ntohl( l );
assert( l < *length );
*length = l;
read( socket, buf, length );
}
-Ken
Kenneth J. Duda
Stanford University Distributed Systems Group
<<A HREF="mailto:kjd@cs.stanford.edu">kjd@cs.stanford.edu</A>>
</pre>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI> Previous message: <A HREF="000338.html">[Nel] newbies about packet schema</A></li>
<LI> Next message: <A HREF="000339.html">[Nel] compile.cpp</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#352">[ date ]</a>
<a href="thread.html#352">[ thread ]</a>
<a href="subject.html#352">[ subject ]</a>
<a href="author.html#352">[ author ]</a>
</LI>
</UL>
</body></html>
|