Revision 15edce59 chunker_streamer/chunk_pusher.c

View differences:

chunker_streamer/chunk_pusher.c
171 171
	return ret;
172 172
}
173 173

  
174
int sendViaTcp(Chunk gchunk, int buffer_size)
174
int sendViaTcp(Chunk gchunk, uint32_t buffer_size)
175 175
{
176 176
	uint8_t *buffer=NULL;
177 177

  
......
183 183
		return ret;
184 184
	}
185 185

  
186
	if( (buffer = malloc(buffer_size)) != NULL) {
186
	if( (buffer = malloc(4 + buffer_size)) != NULL) {
187 187
		/* encode the GRAPES chunk into network bytes */
188
		encodeChunk(&gchunk, buffer, buffer_size);
188
		encodeChunk(&gchunk, buffer + 4, buffer_size);
189
		*(uint32_t*)buffer = htonl(buffer_size);
189 190
		
190
		int ret = send(tcp_fd, buffer, buffer_size, 0);
191
		int ret = send(tcp_fd, buffer, 4 + buffer_size, 0);
192
fprintf(stderr, "TCP IO-MODULE: sending %d bytes, %d sent\n", buffer_size, ret);
191 193
		int tmp;
192 194
		while(ret != buffer_size)
193 195
		{
194
			tmp = send(tcp_fd, buffer+ret, buffer_size-ret, 0);
196
			tmp = send(tcp_fd, buffer+ret, 4 + buffer_size - ret, 0);
195 197
			if(tmp > 0)
196 198
				ret += tmp;
197 199
			else

Also available in: Unified diff