diff --git a/lib/modules/Protocols.pmod/Ident.pmod b/lib/modules/Protocols.pmod/Ident.pmod
index 9c48a1e0ec908f9d0666c02a09b69ac9fdbb08f7..556f1b72f8a11a7c6f5fd507e2ca1dc855e3dd37 100644
--- a/lib/modules/Protocols.pmod/Ident.pmod
+++ b/lib/modules/Protocols.pmod/Ident.pmod
@@ -1,6 +1,6 @@
 // An implementation of the IDENT protocol, specified in RFC 931.
 //
-// $Id: Ident.pmod,v 1.3 1998/04/08 17:25:12 neotron Exp $
+// $Id: Ident.pmod,v 1.4 1998/05/27 05:47:41 neotron Exp $
 
 
 int|array (string) lookup(object fd)
@@ -9,6 +9,7 @@ int|array (string) lookup(object fd)
   mixed laddr; // Local Address.
   array err;
   object remote_fd;
+  int i;
   if(!fd)
     return 0;
   err = catch(raddr = fd->query_address());
@@ -23,21 +24,25 @@ int|array (string) lookup(object fd)
   laddr = laddr / " ";
   raddr = raddr / " ";
 
-  remote_fd = Stdio.File();
+  remote_fd = Stdio.FILE();
   if(!remote_fd->open_socket(0, laddr[0])) {
     destruct(remote_fd);
     throw(backtrace() +({ "Protocols.Ident: open_socket() failed."}));
   }
+
   if(err = catch(remote_fd->connect(raddr[0], 113)))
   {
     destruct(remote_fd);
     throw(err);
   }
-  if(remote_fd->write(raddr[1]+","+laddr[1]+"\r\n") == -1) {
+  remote_fd->set_blocking();
+  string query = raddr[1]+","+laddr[1]+"\r\n";
+  int written;
+  if((written = remote_fd->write(query)) != strlen(query)) {
     destruct(remote_fd);
-    throw(backtrace() +({ "Protocols.Ident: write failed."}));
+    throw(backtrace() +({ "Protocols.Ident: short write ("+written+")."}));
   }
-  mixed response = remote_fd->read();
+  mixed response = remote_fd->gets();//0xefffffff, 1);
   if(!response || !strlen(response))
   {
     destruct(remote_fd);
@@ -46,7 +51,7 @@ int|array (string) lookup(object fd)
   remote_fd->close();
   destruct(remote_fd);
   response -= " ";
-  response -= "\r\n";
+  response -= "\r";
   response /= ":";
   if(sizeof(response) < 2)
     return ({ "ERROR", "UNKNOWN-ERROR" });
diff --git a/lib/modules/Protocols.pmod/NNTP.pmod b/lib/modules/Protocols.pmod/NNTP.pmod
index 0d17910ee38bf01f8cc26dff4349a71e01b8816a..f032fc5712f4f511ee2fcfcc05c0b2410bb7360d 100644
--- a/lib/modules/Protocols.pmod/NNTP.pmod
+++ b/lib/modules/Protocols.pmod/NNTP.pmod
@@ -21,7 +21,8 @@ class protocol
   string *read_body_lines()
   {
     string *ret=({});
-    while(string s=news::gets())
+    string s;
+    while(s = news::gets())
     {
       if(s=="." || s==".\r") return ret;
       sscanf(s,".%s",s);
@@ -53,7 +54,7 @@ class protocol
 
   int command(string cmd)
   {
-    news::write(cmd+"\n");
+    news::write(cmd+"\r\n");
     return readreturncode();
   }
 
diff --git a/lib/modules/Protocols.pmod/SMTP.pmod b/lib/modules/Protocols.pmod/SMTP.pmod
index 65507888567af1b29543af8977fe0355a2b97373..b1d89bdafec7c04eaebbef88775e6aeca15bc98e 100644
--- a/lib/modules/Protocols.pmod/SMTP.pmod
+++ b/lib/modules/Protocols.pmod/SMTP.pmod
@@ -50,7 +50,7 @@ class client
     return r;
   }
 
-  void create(void|string server)
+  void create(void|string server, int|void port)
   {
     if(!server)
     {
@@ -59,7 +59,10 @@ class client
       server=dns->get_primary_mx(gethostname());
     }
 
-    if(!connect(server,25))
+    if(!port)
+      port = 25;
+
+    if(!connect(server, port))
     {
       throw(({"Failed to connect to mail server.\n",backtrace()}));
     }