Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Richard Torres   on Jun 08 In Java Category.

  
Question Answered By: Calandre Bernard   on Jun 08

-----------------------MySocket.java-----------------
import java.net.*;
import java.io.*;
public class MySocket extends Socket implements
Serializable{
MySocket(String host, int port) throws Exception{
super(host,port);
}
}

-----------------TestSocket.java-----------------

import java.io.*;
import java.net.*;
public class TestSocket{
public static void main(String[] args){
try{
MySocket echoSocket = new MySocket("localhost",80);
FileOutputStream fout = new
FileOutputStream("name.out");
ObjectOutputStream dat = new
ObjectOutputStream(fout);
dat.writeObject(echoSocket);
}catch(Exception lvObjEx){
lvObjEx.printStackTrace();
}
}
}

Share: 

 

This Question has 4 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Serialize a Socket Object Or get search suggestion and latest updates.


Tagged: