15,905,682 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 13072690 (Top 3 by date)
Member 13072690
23-Mar-17 10:52am
View
I mean that Can I use closing port on web server to program socket?
Member 13072690
21-Mar-17 22:05pm
View
Ok, I will make a new question
Member 13072690
21-Mar-17 6:06am
View
Thanks for your response. This error is true, however after i corrected, this is error:
Gateway Timeout
The gateway did not receive a timely response from the upstream server or application.
Code Java of client:
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.net.UnknownHostException;
public class WebClient {
public static void main(String[] args) throws IOException {
String host ="ad-box.deslab.vn";
Socket s = null;
BufferedReader br = null;
BufferedWriter bw = null;
try {
s = new Socket(host, 10000);
br = new BufferedReader(new InputStreamReader(s.getInputStream()));
bw = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
} catch (UnknownHostException e) {
System.err.println("Don't know about host: hostname\n");
} catch (IOException e) {
System.err.println("Couldn't get I/O for the connection to: hostname\n");
}
// Send message to server
String message = "FETEL HCMUS";
// String message = "GET / HTTP/1.1\r\n\r\n";
// System.out.println(message);
bw.write(message);
bw.flush();
// Get response from server
String response = "";
while ((response = br.readLine()) != null) {
System.out.println(response);
}
bw.close();
br.close();
s.close();
}
}
Please help me more