May 2nd, 2000, 06:09 PM
Hi
I am using Win NT and using Java application to transfer files from Machine A to Machine B which are in different Network.
Machine A is in Web and got Modem also . Machine B is stand alone machine and connected to Telephone and Modem.
I want to transfer file from Machine A to Machine B through Dial up connection.
From Machine A , what should i do to send the file to Machine B through Dialup connection?
Connection should be established automatically from Machine A to Machine B.
Once the connection is established , i try to send one file to Machine B.
I got following questions to ask:
1. Can I use Javax.comm.* Package for this requirment.
2. If i get connected to Machine thru javax.comm package then how will i transfer file from Machine A to Machine B.
3. If I get connection , then how will i know that i got connected to Machine B.
Can i use the follwing code for establishing connection to other machine.
**********************************************************************************************************************************************************
import java.io.*;
import java.util.*;
import javax.comm.*;
public class telephone
{
static Enumeration portList;
static CommPortIdentifier portId;
//static String messageString = "ATDT 5089033067\r";
static String messageString = "ATDT 15089033092\r";
static SerialPort serialPort;
static OutputStream outputStream;
public static void main(String[] args)
{
portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements())
{
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL)
{
if (portId.getName().equals("COM2"))
{
//if (portId.getName().equals("/dev/term/a"))
try
{
serialPort = (SerialPort)portId.open("SimpleWriteApp", 200);
}
catch (PortInUseException e){e.printStackTrace();}
try
{
outputStream = serialPort.getOutputStream();
}
catch (IOException e){e.printStackTrace();}
try {
serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
}
catch (UnsupportedCommOperationException e) {}
try
{
serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN);
}
catch (UnsupportedCommOperationException e) {}
try
{
System.out.println("MESSAGE IS " + messageString);
outputStream.write(messageString.getBytes());
outputStream.flush();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
}
}
**********************************************************************************************************************************************************
How to check whether I am connected to Machine B thru Dialup??
Can you please throw some light regarding these.
Thanks
I am using Win NT and using Java application to transfer files from Machine A to Machine B which are in different Network.
Machine A is in Web and got Modem also . Machine B is stand alone machine and connected to Telephone and Modem.
I want to transfer file from Machine A to Machine B through Dial up connection.
From Machine A , what should i do to send the file to Machine B through Dialup connection?
Connection should be established automatically from Machine A to Machine B.
Once the connection is established , i try to send one file to Machine B.
I got following questions to ask:
1. Can I use Javax.comm.* Package for this requirment.
2. If i get connected to Machine thru javax.comm package then how will i transfer file from Machine A to Machine B.
3. If I get connection , then how will i know that i got connected to Machine B.
Can i use the follwing code for establishing connection to other machine.
**********************************************************************************************************************************************************
import java.io.*;
import java.util.*;
import javax.comm.*;
public class telephone
{
static Enumeration portList;
static CommPortIdentifier portId;
//static String messageString = "ATDT 5089033067\r";
static String messageString = "ATDT 15089033092\r";
static SerialPort serialPort;
static OutputStream outputStream;
public static void main(String[] args)
{
portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements())
{
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL)
{
if (portId.getName().equals("COM2"))
{
//if (portId.getName().equals("/dev/term/a"))
try
{
serialPort = (SerialPort)portId.open("SimpleWriteApp", 200);
}
catch (PortInUseException e){e.printStackTrace();}
try
{
outputStream = serialPort.getOutputStream();
}
catch (IOException e){e.printStackTrace();}
try {
serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
}
catch (UnsupportedCommOperationException e) {}
try
{
serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN);
}
catch (UnsupportedCommOperationException e) {}
try
{
System.out.println("MESSAGE IS " + messageString);
outputStream.write(messageString.getBytes());
outputStream.flush();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
}
}
**********************************************************************************************************************************************************
How to check whether I am connected to Machine B thru Dialup??
Can you please throw some light regarding these.
Thanks