General Development

TCP Help – rnagene

Junior Member

Posts: 8
From: United States
Registered: 02-28-2007
I'm trying to send information or emails to individual websites. Then the thought came to me that I should send it to anyone but the routine I wrote does not work. My documentation lacks information on TCP and UDP.

Function advertise();theMsg$
;If themsg$=""
; theMsg$ = Input("Please enter the message: ")
While Not KeyHit(1) host$ = Rand(0, 255) + "." + Rand(0, 255) + "." + Rand(0, 255) + "." + Rand(0, 255):the_count=the_count+1
stream% = OpenTCPStream(host$, Rand(0, 255*255) * percent#):If open=0 Print "Transmitting" pen=1
If stream%
Print "Success -> " + host$:WriteLine(fh,"Sent to: "+host$)
WriteLine stream%,amsg$:WriteLine stream%,amsg1$:WriteLine stream%,amsg2$
CloseTCPStream stream%
ElseIf the_count Mod 20000 =0
Print "Still Sending":WriteLine(fh,"Failed: " + host$)
Else WriteLine(fh,"Failed: "+host$)
If the_count>1000000 Then the_count=0
CloseTCPStream stream%
End Function

[This message has been edited by rnagene (edited March 01, 2007).]



Posts: 654
From: Pacific Northwest
Registered: 03-22-2005
TCP and UDP require someone listening to the incoming signal. You can't just send something and expect everyone to hear it. In this sort of typical client/server design, the client opens a listenting port and the server sends to the listening port.

I don't know what language you are using, but based on what I can tell, it looks like you are creating random addresses of where to send your data. In order for this to work, you must SEND and RECEIVE on the same known port.

To get this working, you will need to create a listening client and a sending server. Your code appears to be more like a server with no one listening. Rather than using a random address, you will need to use a known address. You should try something like 'localhost' for the hostname.

I suggest getting the client and server up and running on your local machine ('localhost') and then try communicating with another computer.

I can't offer much more than that as I do not know the language you are using, but all languages typically follow similar patterns. Look at this site: for some help on sockets. It's kind of a long read, but covers what you need to know.

Junior Member

Posts: 8
From: United States
Registered: 02-28-2007
This was written in BB2D.