20.01.2014 Views

Lectures notes for 2010 - KTH

Lectures notes for 2010 - KTH

Lectures notes for 2010 - KTH

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Changed the client<br />

Changing the following:<br />

#define destination_host "127.0.0.1"<br />

#define my_port 52000<br />

server_addr.sin_port=htons(my_port);<br />

Adding some content to the bigBuffer:<br />

sprintf(bigBuffer, "This is a simple test string to be sent to the<br />

other party\n");<br />

Sending only as much of the buffer as necessary:<br />

if ((sendto(client_socket_fd, bigBuffer, strlen(bigBuffer),<br />

sendto_flags, (struct sockaddr*)&server_addr,<br />

sizeof(server_addr))) == -1) {…}<br />

Results in the listener outputting:<br />

Received packet from 127.0.0.1:1260<br />

Data: This is a simple test string to be sent to the other party<br />

String length=59<br />

Maguire Simple UDP client 4: 23 of 74<br />

maguire@kth.se <strong>2010</strong>.03.21 Internetworking/Internetteknik

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!