![]() |
| ||
| Problem with remote applications interaction using URL Hello everyone, beforehand, sorry for my english... I have to do client - server application. They must interact, using classes URL, URLConnection. I understand, how to send data to server. But I can not realize server work. The common algorithm of server is: 1. Start. 2. Wait for connection. 3. After receiving connection it must process request. 4. Or back for "2" or exit. as I understand, client code to send request is: URL url = new URL ("http://" + host + ":" + port);please help with server code to catch this connection? |
| ||
| Re: Problem with remote applications interaction using URL Please, at least somebody! Any help at all would be greatly appreciated! |
| ||
| Re: Problem with remote applications interaction using URL here ya go, just needs slight modification on response and your listening ports http://www.codeproject.com/KB/IP/tcpclientserver.aspx |
| ||
| Re: Problem with remote applications interaction using URL sorry, forgot it was java, here's a sample java tcplistener http://www.koders.com/java/fid857615...7AE75C4F5.aspx |
| ||
| Re: Problem with remote applications interaction using URL Yeah ... THANKS... IT WORKS (almost). So I have another problem: server catches the client connections, but when I'm trying to read from InputStream BufferedReader is = new BufferedReader(new InputStreamReader(socket.getInputStream()));it reads information: " POST / HTTP/1.1 Connection: close Keep-Alive: 300 User-Agent: Java/1.6.0_07 Host: localhost:2604 Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 Content-type: application/x-www-form-urlencoded Content-Length: 38 key1=search%09StudentRecBook%09123" and after that stops at while ((line = is.readLine()) != null)like waiting for reading something else from stream. What he is waiting for? Help :) |
| ||
| Re: Problem with remote applications interaction using URL i don't think it will return null, until the socket gets closed not for sure if this is the terminator, but did you check for "." (period) with crlf? also check -1 |
| ||
| Re: Problem with remote applications interaction using URL I already tried -1 - same. And I took "null" from java help Quote:
|
| ||
| Re: Problem with remote applications interaction using URL nm, think i was thinking of something else can you please post the server and client code, at least the guts part where its sending and receiving |
| ||
| Re: Problem with remote applications interaction using URL Server: private Socket socket = null; Client: private String sendRequest(String request)There was no case in which server send response and client recieves it. So It can be mistakes there... |
| ||
| Re: Problem with remote applications interaction using URL oops.. sorry for russian messages. It is only messages like "Server started" or "IO error". If it necessary I can translate it... :) |
| ||
| Re: Problem with remote applications interaction using URL sorry don't have time to debug it right now, are you getting an ioexception in the server from the first trycatch? |
| ||
| Re: Problem with remote applications interaction using URL sorry to bombard you with links, but here is another server example http://fragments.turtlemeat.com/javawebserver.php |
| ||
| Re: Problem with remote applications interaction using URL Thanks I'll try... |
| ||
| Re: Problem with remote applications interaction using URL and also just to make sure you aren't running client and server on the same machine are you? |
| ||
| Re: Problem with remote applications interaction using URL Quote:
Quote:
|
| ||
| Re: Problem with remote applications interaction using URL ah hah, forgot to look at the previous post, i've had some trouble, normally not, but sometimes yes, just want to try and eliminate all possibilities |
| ||
| Re: Problem with remote applications interaction using URL Oh ... it never ends :( Thanks a lot for spending time working with me and my problem. I have tried new variant - same trouble. I found the way to pass through this problem: I add "\n\n" in the end of request and then when reading from stream I'm checking, if the string ends on "\n\n" i break the cycle. Here is updated server code (reading part): while (true)It is workibg! Just interesting, what is wrong? Have any ideas what is that? :) P.S. about client and server on same machine: this is 3rd home work. Previous 2 also used interacting remote and I tested them on my machine and all works normally. |
| ||
| Re: Problem with remote applications interaction using URL lol it is working and you are asking what is wrong? what part doesn't work? or you mean why it didn't work before? |
| ||
| Re: Problem with remote applications interaction using URL Yeah ... I mean before. I've posted code for case, if someone be interested. |
| ||
| Re: Problem with remote applications interaction using URL i believe its because you have to "tell" the server when you are done sending, since you want the server to send the request back you have to say i'm done, now send the information |
| ||
| Re: Problem with remote applications interaction using URL Maybe. And my "\n\n" was as sample :) I'm newbie in remote interaction, can you tell me, is there any usual way to tell server (client) "That's enough"? |
| ||
| Re: Problem with remote applications interaction using URL depends upon the context, a lot of times you will check to see if bytesRead > -1 or sometimes you check for CRLF (carriage return line feed), other times you will pass how many bytes you will be sending and read until all the bytes have been sent |
| ||
| Re: Problem with remote applications interaction using URL Thanks a lot!!!!!!!!!!!!!!!! |
| All times are GMT -4. The time now is 11:27 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC