A very simplifeid programe for sending MMS file ! If you have MMS t...

A very simplifeid programe for sending MMS file ! If you have MMS t... SearchSearch
Author Message
Forest Luo
New member
Username: Forest_luo

Post Number: 2
Registered: 04-2004
Posted on Monday, April 19, 2004 - 09:48 am:   

import java.net.*;
import java.io.*;

public class SendMMS
{
public static void main(String[] args)
{
//Check arguments.
if(args.length != 1)
{
System.out.println("java SendSMS [MMS file]");
return;
}

//Create file.
File file = new File(args[0]);
//Check file.
if(!file.exists() || !file.isFile())
{
System.out.println("invalid file !");
return;
}
//Get length.
int length = (int)file.length();

try
{
//Create bytes.
byte[] bytes = new byte[length];
//Create file input stream.
FileInputStream fis = new FileInputStream(file);
//Create data input stream.
DataInputStream dis = new DataInputStream(fis);
//Read fully.
dis.readFully(bytes);
//Close data input stream.
dis.close();
//Close file input stream.
fis.close();

//Create socket.
Socket socket = new Socket("192.168.0.11",8080);
//Get output stream.
OutputStream os = socket.getOutputStream();
//Create output stream writer.
OutputStreamWriter osw = new OutputStreamWriter(os);
//Create print writer.
PrintWriter pw = new PrintWriter(osw);
//Write request.
pw.println("POST / HTTP1.0");
pw.println("Accept: */*");
pw.println("Content-Type: application/vnd.wap.mms-message");
pw.println("Content-Length: " + bytes.length);
pw.println("");
pw.flush();
//Write bytes.
os.write(bytes);
//Flush.
os.flush();

//Get input stream.
InputStream is = socket.getInputStream();
while(true)
{
int value = is.read();
//Check value.
if(value == -1)
{
break;
}
System.out.print((char)value);
}
//Close print writer.
pw.close();
//Close output stream writer.
osw.close();
//Close output stream.
os.close();
//Close input stream.
is.close();
//Close socket.
socket.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
AngKangxun
New member
Username: Genmaxi

Post Number: 7
Registered: 03-2004
Posted on Tuesday, April 20, 2004 - 02:40 am:   

hi, this program, does it sends mms?
i could compile it, but where and how to send the mms?
Forest Luo
New member
Username: Forest_luo

Post Number: 5
Registered: 04-2004
Posted on Tuesday, April 20, 2004 - 03:10 am:   

It sends MMS over HTTP.
By using it, you can transmit MMS file to MMSC.
But some MMSC needs authentication.
You can download a MMS Simulator from:
http://www.exdata.com.cn/after/download.htm
AngKangxun
New member
Username: Genmaxi

Post Number: 8
Registered: 03-2004
Posted on Tuesday, April 20, 2004 - 04:12 am:   

so how exactly do u work it?
after compiling and run the program,
all i get is "java SendSMS [MMS file]"
so how to send the mms to phone?
Forest Luo
New member
Username: Forest_luo

Post Number: 6
Registered: 04-2004
Posted on Tuesday, April 20, 2004 - 04:35 am:   

If you want to send MMS file to phone, you need a HTTP interface of MMSC. Normally it is applied by service provider from network operator.
Besides the interface, you need some authentication in the header of HTTP request. It is very different between the verdor of MMSC.

The second way it to send MMS directly from MMS phone.

The third way is to send WAP Push PDU to MMS phone, let it retrieve MMS message from your HTTP server. You can prepare a MMS file under this server.
AngKangxun
New member
Username: Genmaxi

Post Number: 9
Registered: 03-2004
Posted on Tuesday, April 20, 2004 - 05:12 am:   

other then the second way,
do u know how to send an mms for pc to phone?

thanks...
Anonymous
 
Posted on Sunday, August 08, 2004 - 08:31 pm:   

"simplifeid" ? HAHAHAHAHAHAHAHHAHAHA

pathetic