rahafrouz
New Member
اشكال اين بلوك هاي برنامه جاوا چيست؟
this will send:
try {
message mes = new message();
mes.show(t1.getText(), t2.getText());
Socket toserver = new Socket("127.0.0.1", 1001);
//ObjectOutputStream oosserv = new ObjectOutputStream(//nashod
// toserver.getOutputStream());//nashod
PrintWriter p=new PrintWriter(toserver.getOutputStream());//shod
//oosserv.writeObject((message) mes);//nashod
p.print((message)mes);//shod
{
this will recieve:
try {
while(true){
Socket toserver = new Socket("127.0.0.1", 1001);
ObjectInputStream oisserv = new ObjectInputStream(toserver
.getInputStream());
mes1 = (message) oisserv.readObject();
if (mes1 != null) {
String nname = mes1.name;
String nmsg = mes1.msg;
mes1.show(nname, nmsg);//yek method ke chap mikonad
mes1 = null;
}
}
this will send:
try {
message mes = new message();
mes.show(t1.getText(), t2.getText());
Socket toserver = new Socket("127.0.0.1", 1001);
//ObjectOutputStream oosserv = new ObjectOutputStream(//nashod
// toserver.getOutputStream());//nashod
PrintWriter p=new PrintWriter(toserver.getOutputStream());//shod
//oosserv.writeObject((message) mes);//nashod
p.print((message)mes);//shod
{
this will recieve:
try {
while(true){
Socket toserver = new Socket("127.0.0.1", 1001);
ObjectInputStream oisserv = new ObjectInputStream(toserver
.getInputStream());
mes1 = (message) oisserv.readObject();
if (mes1 != null) {
String nname = mes1.name;
String nmsg = mes1.msg;
mes1.show(nname, nmsg);//yek method ke chap mikonad
mes1 = null;
}
}
سلام
من یک مسنجر نوشتم که برای تبادل اطلاعات از فرستادن آبجکت استفاده می کند و از متد های ObjectOutputStrem and Object InputStream استفاده می کند. اول از همه که ObjectOutputStrem کار نکرد و من از کلاس PrintWriter و متد print استفاده کردم و لا اقل ارور نداد ولی ObjectInputStream هیچ کاری نمی کند و چیزی را دریافت نمی کند حالا من چه کنم، آیا می توان از متدی دیگر به جای این استفاده کرد؟ و سوال دیگر اینکه ایا آبجکتی که فرستاده شده که در آن دو متغیر هست را برنامه ی دیگر میشناسد؟(اگر اسم متغیرها یکی باشد)
در قسمتي به مشکل برخوردم که اطلاعات را می گیرد
با تشكر
من یک مسنجر نوشتم که برای تبادل اطلاعات از فرستادن آبجکت استفاده می کند و از متد های ObjectOutputStrem and Object InputStream استفاده می کند. اول از همه که ObjectOutputStrem کار نکرد و من از کلاس PrintWriter و متد print استفاده کردم و لا اقل ارور نداد ولی ObjectInputStream هیچ کاری نمی کند و چیزی را دریافت نمی کند حالا من چه کنم، آیا می توان از متدی دیگر به جای این استفاده کرد؟ و سوال دیگر اینکه ایا آبجکتی که فرستاده شده که در آن دو متغیر هست را برنامه ی دیگر میشناسد؟(اگر اسم متغیرها یکی باشد)
در قسمتي به مشکل برخوردم که اطلاعات را می گیرد
با تشكر