|
sorry, would you expain a bit more about the code provided??? what I have now is client server chat I'm going to upgrade it to the online auction program.
|
|
|
|
|
you said you want to add an item every x minutes to auction so change 10000 to the time you want. Now in the run method here you will write the code for the auctioning process and broadcasting the message. Note that the code will be used in the server code you wrote
|
|
|
|
|
ok, Thanks, I will try and hopefully could get it working.
anyway thanks
|
|
|
|
|
still have problem, I couldnt implement the auctioning (offering items and broadcasting). more help please??!!
|
|
|
|
|
golisarmi wrote: still have problem, I couldnt implement the auctioning
What problem? Please be specific and show the code that is not working, or explain the error that you are seeing.
|
|
|
|
|
The [bad] code was in the original message which the OP decided to delete.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
I myself deleted the original message by accident.
this is my server code:
mport java.net.*;
import java.io.*;
import java.util.*;
public class AuctionServer {
public AuctionServer (int port) throws IOException {
ServerSocket server = new ServerSocket (port);
while (true) {
Socket client = server.accept();
DataInputStream in = new DataInputStream(client.getInputStream());
String name = in.readUTF();
System.out.println ("New client "+name+" from " + client.getInetAddress());
AuctionHandler c = new AuctionHandler (name, client);
c.start ();
}
}
public static void main (String args[]) throws IOException {
if (args.length != 1)
throw new RuntimeException ("Syntax: java AuctionServer <port>");
new AuctionServer (Integer.parseInt (args[0]));
}
}
and client code is :
import java.net.*;
import java.io.*;
import java.awt.event.*;
public class AuctionClient {
public AuctionFrame gui;
private Socket socket;
private DataInputStream in;
private DataOutputStream out;
public AuctionClient(String name, String server, int port) {
gui = new AuctionFrame("Online Auction!!!");
gui.input.addKeyListener (new EnterListener(this,gui));
gui.addWindowListener(new ExitListener(this));
try {
socket = new Socket(server,port);
in = new DataInputStream(socket.getInputStream());
out = new DataOutputStream(socket.getOutputStream());
out.writeUTF(name);
while (true) {
gui.output.append("\n"+in.readUTF());
}
} catch (Exception e) {
e.printStackTrace();
}
}
protected void sendTextToChat(String str) {
try {
out.writeUTF(str);
} catch (IOException e) {
e.printStackTrace();
}
}
protected void disconnect() {
try {
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main (String args[])throws IOException {
if (args.length!=3)
throw new RuntimeException ("Syntax: java AuctionClient <name> <serverhost> <port>");
int port=Integer.parseInt(args[2]);
AuctionClient c=new AuctionClient(args[0], args[1], port);
}
}
and class handler:
import java.net.*;
import java.io.*;
import java.util.*;
public class AuctionHandler extends Thread {
Socket socket;
DataInputStream in;
DataOutputStream out;
String name;
protected static Vector handlers = new Vector ();
public AuctionHandler (String name, Socket socket) throws IOException {
this.name = name;
this.socket = socket;
in = new DataInputStream (new BufferedInputStream (socket.getInputStream()));
out = new DataOutputStream (new BufferedOutputStream (socket.getOutputStream()));
}
public void run () {
try {
broadcast(name+" entered");
handlers.addElement (this);
while (true) {
String message = in.readUTF ();
broadcast(name+": "+message);
}
} catch (IOException ex) {
System.out.println("-- Connection to user lost.");
} finally {
handlers.removeElement (this);
broadcast(name+" left");
try {
socket.close ();
} catch (IOException ex) {
System.out.println("-- Socket to user already closed ?");
}
}
}
protected static void broadcast (String message) {
synchronized (handlers) {
Enumeration e = handlers.elements ();
while (e.hasMoreElements ()) {
AuctionHandler handler = (AuctionHandler) e.nextElement ();
try {
handler.out.writeUTF (message);
handler.out.flush ();
} catch (IOException ex) {
handler = null;
}
}
}
}
}
as Im using Gui for this Auction program now I don't know the code that 'member 42...' provided me where can be put in my codes to set timer first and then auctioning code??
|
|
|
|
|
Please use the "code block" button to put <pre></pre> tags around it and maintain formatting; this is difficult to read.
golisarmi wrote: as Im using Gui for this Auction program now I don't know the code that 'member 42...' provided me where can be put in my codes to set timer first and then auctioning code??
I still don't understand what your problem is here, who or what is member 42?
|
|
|
|
|
i tried your code, it's seems unable to connect and something wrong with ur Frame.. do u miss 1 frame there?
public AuctionFrame gui;<<<<
|
|
|
|
|
mica1314 wrote: i tried your code
I did not post any code! Please respond to the correct person.
It's time for a new signature.
|
|
|
|
|
Hi Guys,
I want to store info into Mysql and retrieve back into console application and display it to the user. Iam new to MySql what are the settings that i have to do and any samples related to it please help me regarding it.
Thanks in Advance.....
sampath-padamatinti
|
|
|
|
|
I dont know how this is related to Java but if you google you can find what you want link1[^] Link2[^]
|
|
|
|
|
can anyone tell me how to do this or file monitor using java and if somebody knw d code then i will be grateful
|
|
|
|
|
You already asked this question once; please do not spam the forums. If anyone has a good suggestion they will give it to you. If you are merely asking for code then do not expect an answer soon, instead use Google.
|
|
|
|
|
Dude make an effort for the installer check out Link[^] I already gave you a link in your old post for registry. For the file monitor check out Link[^]
GOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOGLE
|
|
|
|
|
spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam retarded moron spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
What, no beanz?
|
|
|
|
|
can any help me in telling d code for doing butterfly graphics in turbo c
|
|
|
|
|
|
You are getting yourself a reputation as a wee bit stoopid. Chris has told us to play nice and not hit the other kids, si I won't tell you to "F*** O**!", instead I'll suggest you think about what the relationship between turbo-c and java is...
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Nagy Vilmos wrote: what the relationship between turbo-c and java is...
let me guess:
- they both are unrelated to Visual Basic?
- they both use curly brackets?
- they both are extremely good at painting butterflies?
I give up.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
|
Try this olde skool BASIC example:
10 INPUT NEEDCODE$
20 GOTO RENTACODER
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
nGrafix wrote: I am new in Java programming and and found myself in MSc Software Engineering program now.
And you think the best way to achieve this qualification is to get other people to do your work.
|
|
|
|
|
Well, I'm sure there's some moron here who will post the solution for him. Just wait a couple of minutes.
|
|
|
|