java


Error Creating and connecting to a Socket based server on AWS


I'm looking to connect to a simple socket server I have deployed on AWS' Elastic Beanstalk,
however currently it just degrades and doesn't run.
The service is meant to simply be a hello world socket based server that receives a connection, returns "Hello World" to the client, then closes the connection.
The service is running on Java 8, as a web service, and below is the class for the socket based service.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
public class SocketServer {
/**
* #param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int portNumber = 80;
try (
ServerSocket serverSocket = new ServerSocket(portNumber);
Socket clientSocket = serverSocket.accept();
PrintWriter out =
new PrintWriter(clientSocket.getOutputStream(), true);
BufferedReader in = new BufferedReader(
new InputStreamReader(clientSocket.getInputStream()));
) {
System.out.print("Test");
String inputLine, outputLine;
// Initiate conversation with client
outputLine = "Hello World";
out.println(outputLine);
clientSocket.close();
} catch (IOException e) {
System.out.println("Exception caught when trying to listen on port "
+ portNumber + " or listening for a connection");
System.out.println(e.getMessage());
}
}

Related Links

Handling JSON Webhook in JAVA Google App Engine
HTTP Error 401 while calling RESTFul Web service from a RESTFul client (both are on the same security domain) in JBOSS EAP 6.3
Converting to ExecutorService
Lombok delombok option doesn't generate code for #Nonnull check
Cant generate java code from wsdl file
Jar with multiple main
EasyMock - mock object returned from new Object
Mockito: how to stub inherited methods
Java Making a Custom Report PDF with iText
Calculations between two integer arrays
how to add utf8 text to image with diffrent ttf fonts?
How is it getting an instantiation error and how to fix it? [Android]
Locations saved in sqlite not shown in list [duplicate]
Array list iterators next and previous not working
Is there a way to control windows in another Java process?
JBoss Singleton Service Example: Does not expose a singleton object

Categories

HOME
isabelle
spagobi
adb
filtering
v8
ip
alpha
ezpublish
autotools
append
synchronization
user-input
correlation
event-handling
ibm-odm
ups
decimal
vaadin7
workload-scheduler
pugjs
apache-metamodel
firefox-webextensions
cx-freeze
google-search-api
captiveportal
java-7
pingfederate
kendo-datasource
.net-4.0
catch-all
avcapturesession
openoffice.org
automake
xenforo
reportbuilder
temporary-files
azure-ml
cookiecutter-django
trim
broadcastreceiver
optix
mapzen
ibpy
spring-security-kerberos
fakeiteasy
scorm
angular-resource
celery-task
elgg
forever
csound
nodebb
font-size
django-scheduler
topbeat
objective-c-swift-bridge
ado.net-entity-data-model
url-masking
intrusion-detection
disque
ubuntu-10.04
qcustomplot
master-slave
rvest
teamcity-8.0
google-places
rgeo
angular-leaflet-directive
varargs
fluid-dynamics
oxwall
camanjs
qcodo
socketexception
websocket4net
android-radiobutton
reactfx
mbr
floating-point-precision
page-layout
quantlib-swig
runtime.exec
dotnetnuke-5
bulkloader
sharp-repository
ember-app-kit
labwindows
hosts-file
uiviewanimation-curve
osql
assembly-loading
stage
doh
psi
appender
ecl
winbugs14
propagation
gamequery
vc90
web-architecture
webkit.net
nintendo-ds
defensive-programming
lzh

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App