- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
int my_number = count-1;
int addition_size =18;
if(sock >= 0)
{
while(1)
{
bytes_read = recv(sock, buf, 1024, 0);
if(bytes_read <= 0) break;
send_buf[0]='r';
send_buf[1]='e';
send_buf[2]='c';
send_buf[3]='e';
send_buf[4]='i';
send_buf[5]='v';
send_buf[6]='e';
send_buf[7]='d';
send_buf[8]=' ';
send_buf[9]='m';
send_buf[10]='e';
send_buf[11]='s';
send_buf[12]='s';
send_buf[13]='a';
send_buf[14]='g';
send_buf[15]='e';
send_buf[16]=':';
send_buf[17]=' ';
for(i=addition_size;i<addition_size+bytes_read;i++)
send_buf[i]=buf[i-addition_size];
for(i=0;i<count;i++)
if(i != my_number)
send(active_sockets[i], send_buf, bytes_read+addition_size, 0);
}
close(sock);
for(i=my_number;i<count-1;i++)
active_sockets[i]=active_sockets[i+1];
count--;
}