Forums

Where to find cobra mono smtp client informations ?

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Where to find cobra mono smtp client informations ?

Postby Achletomeniak » Wed Jan 10, 2018 6:21 am

Hi there ,

hope to find some informations about Smtp pop client in mono.
I have looked in Mono Documentation. There is only C# code explained.
Where to start ? :roll:

My interest is in the general networking functions such like TCP/IP and other for inplementing
networking function in an application with cobra code. Not : C# code
Thus any example code for those that is explaining the "includings of such libraries inside Mono"
in the cobra code would be a pleasant matter. :mrgreen:

The matter is to beat languages like Python that have networking libraries in and also some clear and
practical examples. :shock:
I MEAN THIS EXAMPLES FROM PYTHON STANDARD LIBRARY:
Code: Select all
>>> from urllib.request import urlopen
>>> with urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl') as response:
...     for line in response:
...         line = line.decode('utf-8')  # Decoding the binary data to text.
...         if 'EST' in line or 'EDT' in line:  # look for Eastern Time
...             print(line)

<BR>Nov. 25, 09:43:32 PM EST

>>> import smtplib
>>> server = smtplib.SMTP('localhost')
>>> server.sendmail('soothsayer@example.org', 'jcaesar@example.org',
... """To: jcaesar@example.org
... From: soothsayer@example.org
...
... Beware the Ides of March.
... """)
>>> server.quit()


Mono has definetly networking protocolls in but in C# language.
Thus an example in Cobra is a must in my opinion. :!:

ONLY COBRA ! Cobra can beat Python. That is a shure thing. But everyone must SEE the methods.

WBR
Ach
Achletomeniak
 

Re: Where to find cobra mono smtp client informations ?

Postby hopscc » Thu Jan 11, 2018 10:01 pm

If you've found C# code using networking you have everything you need.
All you have to do is write or convert the C# code to corresponding cobra code - or write cobra code accessing the same C# library API.

I dont have any examples for smtp but heres one for a SocketServer

# Sample for a Server using .Net sockets
# convert from <!-- m --><a class="postlink" href="http://www.c-sharpcorner.com/UploadFile/dottys/SocketProgDTRP11222005023030AM/SocketProgDTRP.aspx">http://www.c-sharpcorner.com/UploadFile ... gDTRP.aspx</a><!-- m -->
#
use System.IO
use System.Net
use System.Net.Sockets

class AsynchIOServer
def main is shared
tcpListener = TcpListener(1032)
tcpListener.start
socketForClient = tcpListener.acceptSocket
if socketForClient.connected
#Console.writeLine("Client connected")
print "Client connected"
networkStream = NetworkStream(socketForClient)
streamWriter = System.IO.StreamWriter(networkStream)
streamReader = System.IO.StreamReader(networkStream)
theString = "Sending"
streamWriter.writeLine(theString)
#Console.writeLine(theString)
print theString
streamWriter.flush
theString = streamReader.readLine to !
#Console.writeLine(theString)
print theString
streamReader.close
networkStream.close
streamWriter.close

socketForClient.close
#Console.WriteLine("Exiting...")
print "Exiting..."


Heres the corres Socket client

# Sample for a Socket client using .Net sockets
# convert from <!-- m --><a class="postlink" href="http://www.c-sharpcorner.com/UploadFile/dottys/SocketProgDTRP11222005023030AM/SocketProgDTRP.aspx">http://www.c-sharpcorner.com/UploadFile ... gDTRP.aspx</a><!-- m -->
#
use System.IO
use System.Net
use System.Net.Sockets

class Client

def main is shared
#args = CobraCore.commandLineArgs
try
socketForServer = TcpClient("localHost", 1032)
catch
#Console.WriteLine("Failed to connect to server at 0:999", "localhost")
print "Failed to connect to server at 0:999", "localhost"
return

networkStream = socketForServer.getStream
streamReader = System.IO.StreamReader(networkStream)
streamWriter = System.IO.StreamWriter(networkStream)
try
outputString as String?
# read the data from the host and display it
outputString = streamReader.readLine
print outputString # Console.WriteLine(outputString)
streamWriter.writeLine("Client Message")
print "Client Message" # Console.WriteLine("Client Message")
streamWriter.flush
catch
print "Exception reading from Server" #Console.WriteLine("Exception reading from Server")


( thought I had some converted examples from the .Net.Sockets sample code ( C# converted to cobra) but couldnt find them.
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand


Return to Discussion

Who is online

Users browsing this forum: No registered users and 12 guests

cron