Want help in sockets
welll my problem is very simple one ....
i want to send request to server from my client side gui .....
.... its like that
i have one class server which uses socket server.......to connect by port........
server.class .....
i have one class client which uses socket to connect to serversocket.........
client is running a gui..... which is like a chat window.......whenever u press a button it will get text from textfield and then its will add to list ..............
my problem is that i want to send same string to server which is adding in list................
here is the codess of 3 classes.........
first server.class
public class Server
ServerSocket ss;
Socket s;
InputStream in;
OutputStream out;
String temp;
Server() throws Exception
new InputStreamReader(System.in);
ss = new ServerSocket(1357);
System.out.println("Waiting on port 1357");
s = ss.accept(); // waiting here
System.out.println("Client connectionestablished");
in = s.getInputStream();
out = s.getOutputStream();
DataInputStream read = new DataInputStream(in);
PrintStream write = new PrintStream( out );
while (true){
temp = read.readLine(); // reading request
write.println("i get u ");
System.out.println(" msg from client"+temp);
// s.close();
/////////////////////// now client side code ///////
public class Client
Socket s;
Client() throws Exception
s = new Socket("localhost", 1357);
System.out.println("Connected to on port 1357");
InputStream in = s.getInputStream();
OutputStream out = s.getOutputStream();
PrintStream write = new PrintStream( out );
DataInputStream read = new DataInputStream(in);
//////////////////////////calling gui//////////////////////
Framee ff=new Framee();
ff.Do();//////////prints gui
String abc=" ";
while(true){
abc=ff.GetSend();
write.println(abc); //REQUEST
String temp = read.readLine(); //READING RESPONSE
System.out.println("Response server " + temp);
/////////////////////////////now Gui classs/////////////////////////////////////
.....GUi(){
public void Do(){
f = new Frame();
b1 = new Button("Ok");
tf1 = new TextField(10);
b1.addActionListener(new Alist());
b2 =new Button("close");
b2.addActionListener(new Alist());
l = new List();
BorderLayout bl= new BorderLayout();
f.setLayout(bl);
l.add(" ");
f.add(l, BorderLayout.CENTER);
f.add(b2, BorderLayout.NORTH);
f.add(b1, BorderLayout.WEST);
f.add(tf1, BorderLayout.SOUTH);
f.setSize(300,300);
f.setTitle("This is the title");
f.show();
public String GetSend(){
String get=" ";
get = l.getSelectedItem();
// get=tf1.getText();
return get;
public class Alist implements ActionListener
public void actionPerformed(ActionEvent e){
if(b2== e.getSource())
System.out.println(" na ");
System.exit(0);
if(b1==e.getSource()){
String get=" ";
get=tf1.getText();
l.add(get);
tf1.setBackground(Color.CYAN);
// System.out.println(" yaap >>> "+get);
tf1.setText(" ");
..................................... now i want that wtever is in List l of Gui ....it should be going to server......and aslo server and client should nt keep the cpu busy ....as they r doing in that code....... thanks in advance
first you will have to digitize the stream, then cut it up into packets of handlable size, then you just sent them out over a valid socket connection.
Yes, I know this is very simple, what part are you having toubles with?
Similar Messages
-
Want help in Vioce transfer on a socket
Dear Buddies
Want help in Vioce transfer on a socket
Tell me how should I start it. I am new to Java World. but good in C/C++
I knew much about sockects. I have to make application which transfere real time voice from both side.first you will have to digitize the stream, then cut it up into packets of handlable size, then you just sent them out over a valid socket connection.
Yes, I know this is very simple, what part are you having toubles with? -
Sorry but i have a problem my IPAD has been stolen and i want help to know where is the place of it ? can i send the serial number or anything i want help to know the place of my IPAD and thanks My name is :- Osama Rezk I'm From :- Egypt my icloud ID
<Email Edited by Host>You will only be able to track your iPad if you have find my iPhone active and the iPad is connected to a network.
Take a look at this link, http://support.apple.com/kb/PH2580 -
I want help, not a post in a forum I can never find again
I want help, not a post in a forum i can never find
http://helpx.adobe.com/indesign.html
http://helpx.adobe.com/indesign/topics.html
There's even a 20mb PDF here with all the Help Topics - http://helpx.adobe.com/pdf/indesign_reference.pdf -
plz i want help , how can i use credit card visa , im try to fill blank no. card information when i finish appear me msg ( the payment card you entered is not valid in israel p;ease provide avalid payment card for israel , im from palestine ) plz solutio?
Oh thank god i am not the only one with this problem. It started with me on Saturday (aug 28) and still, no solution.
I live in the border with the USA so i’ve been using my itunes account with a USA debit card and then it started with that **** declined CC problem =S
The funny thing is that i’ve been trying to change countries, setting my account to Mexico and it would still say that the CC are declined. Tried 2 USA cards and 2 Mexican cards, no results =S
Wanna read something funny. I even tried to create a brand new account based in Mexico, with another email address and it still wouldn’t let me, tells me my cards are not valid……..the **** apple!!! i cannot update any app and i just got my iphone 4 on friday last week and i am dying to try new apps.
So far I’ve sent 2 emails and still no **** solution. At least i am not alone =’( -
Want help in rdesktop software
friends i want help in installing the rdesktop software plesae tel me the guid of installing rdesktop software . where i can find the rdesktop installation guid
regards
AsifI had a look around for some solaris binaries for rdesktop but the only link I could find was broken.
The software was, however, very easy to compile. The instructions in the README file are pretty standard and should work for most Solaris installs.
./configure
make
make install
This installs the software into /usr/local by default.
These worked fine for me although you will of course have to make sure you install gcc and openssl (As these are both used by rdesktop). You can get these from www.sunfreeware.com. Install them, unpack the rdesktop distribution change into he rdesktop directory and run the 3 commands above.
Sean -
My Macbook Air broke. Please help me, Russian Apple Customer Support don't want help me. I'm in despair.
Hi, I bought my MacBook Air in your store. In the summer of 2012. My mac is included in the program MacBook Air Flash Storage Drive Replacement Program. I live in Russia. I called the Russian support Apple. They told me to bring mac to an authorized service center. An authorized service center I was told to wait 45 days of the new flash storage drive. It's very long for me. I can `t wait long. I work on a Mac. I do not have another computer. Russian support Аpple does not want to help me. Can you help me? Serial number my MacBook Air : c0*******rvc
<Personal Information Edited by Host>Leaving you without a computer for 45 days isn't acceptable. Call Apple and ask for a loaner or replacement. Some people have been receiving them.
If you still have no luck, then consider getting a USB 3.0 HDD and installing and running OS X on it until the replacement part is in. -
hello ,
i want help on
Step-By-Step Installation of RAC on Windows NT/2000
plz help me .
PankajIt would be interesting to go through with
Step-By-Step Installation of RAC with RAW Datafiles on Windows 2000
</b><br><br> hare krishna<br> Alok<br> -
I want my Test Sockets will run in loop
I want my Test Sockets will run in loop. I use BatchModel, sequential batch mode.
Now it works so:
process setup
main sequence of Socket 1...
main sequence of Socket 2...
main sequence of Socket N...
process cleanup
I want to do so:
process setup
loop 1
main sequence of Socket 1...
main sequence of Socket 2...
main sequence of Socket N...
loop 2
main sequence of Socket 1...
main sequence of Socket 2...
main sequence of Socket N...
loop N
main sequence of Socket 1...
main sequence of Socket 2...
main sequence of Socket N...
process cleanup
How can I do it ?Marta,
Try using the PreUUTLoop and PostUUTLoop callbacks instead of ProcessSetup and ProcessCleanup.
Allen P.
NI -
I've sent my i phone to technical service because of voice error. I can not talk without a headphone. sometimes screen is freezing. "Teleservice" is the authorizated service in Turkey. even my i phone is in the guarrante scope, service told me to change my iphone with the same i phone by paying 654 euro. I am aggrieved. I want help.
I could not use my phone since i !ve bought it. Because it has always same problems. please help me.
Thanks in advanced.
MineDid you buy it in Turkey (Turkcell or Vodafone)? If you did so, you have 2 years warranty from Gempa,KVK or another company for your iPhone. Also many technical services repair iPhones if you bought it from a foreign country though no luck from Gempa in this case. As I know there is no Genius Bar or AppleCare option for Turkey.
-
Hi,
I am new to SAP BASIS . I want to understand the Tcode functionalities . is there any books or links to study ..
For example in DB02 i can see many buttons like Space statistics ,Current sizes etc...
Please help mefirst you will have to digitize the stream, then cut it up into packets of handlable size, then you just sent them out over a valid socket connection.
Yes, I know this is very simple, what part are you having toubles with? -
I would appreciate if someone could help on the following problem
Scenario:
1, Socket client is running on AS400 written using Java.
2, I am trying to connect to a Unix box from AS400 using the above java socket client I am getting the following error.
Couldn't get I/O for the connection to: venus.
Exception :A remote host refused an attempted connect operation.
java.net.ConnectException: A remote host refused an attempted connect operati
on.
java/lang/Throwable.<init>(Ljava/lang/String;)V+4 (Throwable.java:81)
java/net/PlainSocketImpl.connectToAddress(Ljava/net/InetAddress;I)V+14
(PlainSocketImpl.java:124)
java/net/PlainSocketImpl.connect(Ljava/net/InetAddress;I)V+10 (PlainSoc
ketImpl.java:111)
java/net/Socket.<init>(Ljava/lang/String;I)V+5 (Socket.java:89)
testAS400e.main([Ljava/lang/String;)V+0 (testAS400e.java:21)
Can someone throw some light on this?
Your help would greatly appreciated.This is the error you will get if you cannot connect to a host. This is a normal error that your program should be able to handle. Probably you are trying to connect to the host at a port that no program is listening on. If you can telnet to that port, from the same machine then your jvm is messed up, otherwise it's a network problem.
In java, all connection problems, DNS lookup problem, connection errors, routing errors ,etc... show up as exceptions thrown whenever the problem is encountered. During connection , during read/write to the socket, whatever. So whenever you do anything with the socket, be prepared to encounter an error. Most of the time you can only try to reconnect and restablish the state you were in last, but that is not always possiable.
If you are trying to do a simple HTTP transaction, I would suggest using the java.net.URL class as it will do most of the work you want for you. If you are using the newest 1.4 jdk, then it will even handle ssl tranasctions. -
Need help with Socket prog using Java wireless toolkit
Hi, I am not able to communicate between client (Palm emulator) and server (Java on computer) using Java Wireless toolkit.
Can anyone please tell me a site that shows an example. I have seen a bunch of examples but they all run by importing com.sun.kjava which seems to have vanished into thin air. So I cannot run them. Someone please show me some lines of code that will send just one character from client Palm emulator to server. thanks.
Syedhi,
I hope that you already have the J2ME Toolkit and that your emulator works okay. In the toolkit you get several examples to show you how to program a MIDlet. One has to do with a HTTP client server connection. Also in the API documentation for the J2ME there is a Connector class that you used to set up this communication and in the description of this class it pretty thoroughly explains how to set up an HTTP protocol client.
However, if you want to do some other kind of networking then you are pretty much out of luck, as the TCPIP socket protocol has not been fully implemented and is optional to the J2ME specifications, only the HTTP protocol is certain to be available. This means that mobile phone companies can add other networking functionality to their phone's java virtual machine if they feel like it. This is a bummer I know.
I hope this helps.
Cheers,
Mark -
Hi,
I need help ... please ... I have to use socket and not HTTPURLConnection
I try to connect with a socket to a web server (apache2) and request one page but two times.
The first time it works well but the second one it doesn't ... I get a null message.
Why ?
Does the server close the socket as soon as the page is sent ?
If it doesn't how I can continue sending and receiving data on the same socket ?
Here is my code:
package test;
import java.net.*;
import java.io.*;
public class Test
private String laRequete = new String(
"POST http://localhost:5577/Test/ HTTP/1.0\r\n"+
"Host:localhost:5577\r\n"+
"\r\n");
PrintWriter laSortie;
BufferedReader lEntree;
Socket laSocketTCP;
public Test()
String tmp;
try
laSocketTCP = new Socket("localhost", 5577);
laSortie = new PrintWriter(laSocketTCP.getOutputStream());
lEntree = new BufferedReader(new InputStreamReader(laSocketTCP.getInputStream()));
laSortie.println(laRequete);
laSortie.flush();
// Premier essai OK
System.out.println(lEntree.readLine());
while((tmp = lEntree.readLine()) != null)
System.out.println(tmp);
// Second essai => Not OK
laSortie.println(laRequete);
laSortie.flush();
System.out.println(lEntree.readLine());
while((tmp = lEntree.readLine()) != null)
System.out.println(tmp);
catch (Exception e)
e.printStackTrace();
public static void main(String args[])
Test tp = new Test();
Here is the result of the execution
HTTP/1.1 200 OK
Date: Wed, 29 Sep 2004 08:35:35 GMT
Server: Apache/2.0.51 (Win32)
Last-Modified: Wed, 29 Sep 2004 08:27:57 GMT
ETag: "23a46-9a-56c93f9a"
Accept-Ranges: bytes
Content-Length: 154
Connection: close
Content-Type: text/html; charset=ISO-8859-1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Index Test 1 </TITLE>
</HEAD>
<BODY>
Test 1
</BODY>
</HTML>
null
Thanks, bye.Send an HTTP 1.1 request instead of a 1.0 request.
HTTP 1.0 does not support keeping the connection open, so yes, the server closes the connection.
Dave. -
Want help with "Could not set up your CS Live account. Try again later."
Hi Folks
I've got an NFR of CS6 and I'm trying to give Adobe Story a shot.
Seems it requires online content and a CS Live account to do anything.
But when I try to create one it dies with the error message:
Account setup not completed
Could not set up your CS Live account. Try again later.
Can you help?
Joe
UPDATE: Downloaded update and that fixed things.
However, turns out my NFR of CS6 Production Premium doesn't allow me to use Story.
And here all I wanted to to do try out the transcription features of Premiere Pro.
Without a script it's complete gobbledygook. Would like to try it with a script but it appears I need Story to convert my PDF to Adobe Story format.
Oh well.I ran into the same problem you did, Joe. I just realized Story is all online now. Story.Adobe.com
Maybe you are looking for
-
Download error in Creative Cloud app for desktop Windows 8
Hello everyone. So i have this in my adobe app. What i tried: 1) stop process of Adobe Creative Cloud in task manager 2) reboot 3) change networks to different one , including to internet from mobile phone 4) install-reinstall 5) delete C:\Users\****
-
Hi guys~ I've bought my first thinkpad x230 from lenovo offical online store and recived it on yesterday. I was very exciting when I receive this extreamely light and pretty notebook. -However, it not last long... After typing a series of numbers, th
-
PC's can't see all of my .html page but my mac does.
RE: http://www.todaysipnchat.sipnchat.ca/table.html Can anyone help me figure out why my web page is only partially visible to PC's? I built the page with Site Studio 1.7 on my Linux Server and have a table page with the top and right bottom tables v
-
IPod does not charge or turn on but is recognized in Windows and iTunes
A couple of days ago after disconnecting my iPod in iTunes the iPod display went blank. It will not turn on nor will it display if it is charging if it is connected to the wall power adapter. I tried reseting it and I let it sit for 24 hours like the
-
Work flow for invoice verification
I would like to know how to find out/display the workflow related to MIRO transaction code, miro is invoice verification, how to find the z table created for this workflow. given a work flow template number, how to view this template thanks