commit 6ea519a138b859e8917b0b66fcf9a4d595000046
parent fd111efa2687ca5163077cf4377b0effe0449ced
Author: Marcel <mtrnord1@gmail.com>
Date: Mon, 16 Jan 2017 10:46:08 +0100
(add) Basic Rust Lib structure added
Diffstat:
2 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "irc"
+version = "0.1.0"
+authors = ["Marcel <mtrnord1@gmail.com>"]
+
+[dependencies]
+bufstream = "0.1"
diff --git a/src/lib.rs b/src/lib.rs
@@ -0,0 +1,19 @@
+extern crate bufstream;
+mod irc {
+ fn connect(host: String) {
+ use std::net::{IpAddr, Ipv4Addr, SocketAddr, TcpStream};
+ use std::io::Write;
+ use bufstream::BufStream;
+ let host_split: Vec<&str> = host.split('.').collect();
+ let ServerAddress = IpAddr::V4(Ipv4Addr::new(host_split[0].as_bytes()[0], host_split[1].as_bytes()[0], host_split[2].as_bytes()[0], host_split[3].as_bytes()[0])); // Connect to localhost
+ let ServerPort = 6667;
+ let SocketAddress = SocketAddr::new(ServerAddress, ServerPort);
+ let mut isConnected = false;
+
+ let mut stream = BufStream::new(TcpStream::connect(SocketAddress).unwrap());
+
+ stream.write(b"NICK rustbot\r\n");
+ stream.write(b"USER rustbot 8 * :rustbot\r\n");
+ stream.flush();
+ }
+}