Advertisement
Advertisement
| 03.06.2008 at 02:38PM PST, ID: 23221385 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: |
using System;
using System.Net;
using System.Text;
using System.Windows.Forms;
namespace SATest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
textBox1.Text += "Preparing data...\r\n";
StringBuilder SB = new StringBuilder();
SB.Append("PROCESS SPAMC/1.0");
SB.Append("\r\nSubject: Test spam mail (GTUBE)");
SB.Append("\r\nMessage-ID: <gtube1.1010101@example.net>");
SB.Append("\r\nDate: Wed, 23 Jul 2003 23:30:00 +0200");
SB.Append("\r\nFrom: Sender <sender@example.net>");
SB.Append("\r\nTo: Recipient <recipient@example.net>");
SB.Append("\r\nPrecedence: junk");
SB.Append("\r\nMIME-Version: 1.0");
SB.Append("\r\nContent-Type: text/plain; charset=us-ascii");
SB.Append("\r\nContent-Transfer-Encoding: 7bit");
SB.Append("\r\n");
SB.Append("\r\nIf your spam filter supports it, the GTUBE " +
"provides a test by which you");
SB.Append("\r\ncan verify that the filter is installed " +
"correctly and is detecting incoming");
SB.Append("\r\nspam. You can send yourself a test mail " +
"containing the following string of");
SB.Append("\r\ncharacters (in upper case and with no white " +
"spaces and line breaks):");
SB.Append("\r\n");
SB.Append("\r\nXJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-" +
"ANTI-UBE-TEST-EMAIL*C.34X");
SB.Append("\r\n");
SB.Append("\r\nYou should send this test mail from an " +
"account outside of your network.");
SB.Append("\r\n");
Byte[] buffer = Encoding.ASCII.GetBytes(SB.ToString());
textBox1.Text += "Sending data...\r\n";
System.Net.Sockets.Socket socket =
new System.Net.Sockets.Socket(
System.Net.Sockets.AddressFamily.InterNetwork,
System.Net.Sockets.SocketType.Stream,
System.Net.Sockets.ProtocolType.Tcp);
IPEndPoint ipe =
new IPEndPoint(IPAddress.Parse("192.168.31.128"), 783);
//This is the line on which the error occurs:
socket.Connect(ipe);
socket.Send(buffer);
socket.Shutdown(System.Net.Sockets.SocketShutdown.Send);
textBox1.Text += "Receiving data\r\n";
Int32 r;
do
{
Byte[] recbuf = new Byte[1024];
r = socket.Receive(recbuf);
textBox1.Text += Encoding.ASCII.GetString(recbuf, 0, r);
}
while (r != 0);
textBox1.Text += "OK\r\n";
}
catch (Exception ex)
{
textBox1.Text += "\r\n" + ex.ToString() + "\r\n";
}
}
}
}
|