Skip to content
Snippets Groups Projects
Commit 7aa4c5b0 authored by Terry D. Norbraten's avatar Terry D. Norbraten
Browse files

Merge origin/master

Conflicts:
	examples/src/UdpMulticastExamples/UdpSender.java
parents 4ee5e60b eb22510e
No related branches found
No related tags found
No related merge requests found
......@@ -31,3 +31,34 @@ GET /index.html HTTP/1.0
15: </body></html>
HttpWebPageSource: response finished
BUILD SUCCESSFUL (total time: 2 seconds)
now using https to port 443:
run-single:
HttpWebPageSource: create http connection and retrieve default page
Reference: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
Reference: https://tools.ietf.org/html/rfc7230
Reference: https://en.wikipedia.org/wiki/CURL
New socket WEB_ADDRESS=www.nps.edu
GET /index.html HTTP/1.0
1: HTTP/1.1 400 Bad Request
2: Date: Mon, 17 Aug 2020 18:25:20 GMT
3: Server: Apache
4: Content-Length: 362
5: Connection: close
6: Content-Type: text/html; charset=iso-8859-1
7:
8: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
9: <html><head>
10: <title>400 Bad Request</title>
11: </head><body>
12: <h1>Bad Request</h1>
13: <p>Your browser sent a request that this server could not understand.<br />
14: Reason: You're speaking plain HTTP to an SSL-enabled server port.<br />
15: Instead use the HTTPS scheme to access this URL, please.<br />
16: </p>
17: </body></html>
HttpWebPageSource: response finished
BUILD SUCCESSFUL (total time: 2 seconds)
File added
examples/src/HttpServletExamples/JavaServletArchitecture.png

160 KiB

File added
......@@ -20,10 +20,12 @@ public class UdpSender
{
// System properties: https://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html
public static final String MY_NAME = System.getProperty("user.name"); // guru incantation 8)
public static final int SENDING_PORT = 1414;
// public static final int SENDING_PORT = 1414; // not needed, can let system choose an open local port
public static final int RECEIVING_PORT = 1415;
public static final int TOTAL_PACKETS_TO_SEND = 100;
public static final String DESTINATION_HOST = "localhost"; // localhost 127.0.0.1 or argon 10.1.105.1
// here is what we need for lab comms
public static final String DESTINATION_HOST = "10.1.105.16"; // localhost 127.0.0.1 or argon 10.1.105.1 or 10.1.105.1 or whatever
@SuppressWarnings("SleepWhileInLoop")
public static void main(String[] args) throws IOException
......@@ -32,8 +34,8 @@ public class UdpSender
DataOutputStream dos = null;
int packetID = 0; // counter variable to send in packet
float value = -1.0f; // unreachable value is good sentinel to ensure expected changes occur
String message = "Hello from " + MY_NAME; // no really
String padding;
String message = MY_NAME + " says Hello MV3500"; // no really
String padding = new String();
try
{
......@@ -41,7 +43,7 @@ public class UdpSender
System.out.println(UdpSender.class.getName() + " started...");
// Create a UDP socket
udpSocket = new DatagramSocket();
udpSocket = new DatagramSocket(); // let system assign output port, then SENDING_PORT not needed
// Put together a message with binary content. "ByteArrayOutputStream"
// is a java.io utility that lets us put together an array of binary
......@@ -68,8 +70,8 @@ public class UdpSender
for (int index = 1; index <= TOTAL_PACKETS_TO_SEND; index++) // avoid infinite send loops in code, they can be hard to kill!
{
packetID++; // increment counter, prefer using explicit value to index
value = 100 - packetID; // countdown
packetID++; // increment counter, prefer using explicit value to index
value = TOTAL_PACKETS_TO_SEND - packetID; // countdown
boolean isPacketIdEvenParity = ((packetID % 2) == 0); // % is modulo operator; result 0 is even parity, 1 is odd parity
// values of interest follow. order and types of what was sent must match what you are reading!
......@@ -82,6 +84,7 @@ public class UdpSender
byteArray = baos.toByteArray(); // OK so go get the flushed result...
datagramPacket.setData(byteArray); // and put it in the packet...
udpSocket.send(datagramPacket); // and send it away. boom gone, nonblocking.
// System.out.println("udpSocket output port=" + udpSocket.getLocalPort()); // diagnostic tells what port was chosen by system
if (isPacketIdEvenParity)
padding = " ";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment