0

Is it possible to connect to a server with sub-directory?

for example: www.example.com:80/server.

I want to receive the data from the server with a Socket.

Something like this:

String url = "example.com:80/server";
Socket client = new Socket(url);
Code Lღver
  • 15,573
  • 16
  • 56
  • 75
marnix
  • 60
  • 8
  • I think you are confusing protocol layers. A `Socket` has no concept of a *directory*, that is a higher level concept, in your case probably of HTTP. Why not use `URL.openConnection()`? – dhke Apr 03 '15 at 10:14

1 Answers1

0

Subdirectories are a high level concept in protocols like HTTP and FTP. Based on your example, you look like you're trying to connect to a HTTP port. This won't work for you because you'd have to write all of the code to implement the HTTP protocol to the point where you could send valid requests and handle the responses. If that's what you want to do, you should just one of the many high level HTTP libraries out there.

If you just want to create a simple server app, just open a socket on example.com, port 80 and write your own messages/responses for saying you want folder server. The custom server will have to know how to handle your own messages, read folders, etc.

Mike Thomsen
  • 36,828
  • 10
  • 60
  • 83