Index: /pjproject/branches/symbian/pjlib/src/pj/addr_resolv_symbian.cpp
===================================================================
--- /pjproject/branches/symbian/pjlib/src/pj/addr_resolv_symbian.cpp	(revision 805)
+++ /pjproject/branches/symbian/pjlib/src/pj/addr_resolv_symbian.cpp	(revision 806)
@@ -40,8 +40,11 @@
     // Resolve!
     TNameEntry nameEntry;
-    TInt rc = resv.GetByName(data, nameEntry);
-
-    if (rc != KErrNone)
-	return PJ_RETURN_OS_ERROR(rc);
+    TRequestStatus reqStatus;
+    
+    resv.GetByName(data, nameEntry, reqStatus);
+    User::WaitForRequest(reqStatus);
+    
+    if (reqStatus != KErrNone)
+	return PJ_RETURN_OS_ERROR(reqStatus.Int());
 
     // Get the resolved TInetAddr
Index: /pjproject/branches/symbian/pjlib/src/pj/ioqueue_symbian.cpp
===================================================================
--- /pjproject/branches/symbian/pjlib/src/pj/ioqueue_symbian.cpp	(revision 805)
+++ /pjproject/branches/symbian/pjlib/src/pj/ioqueue_symbian.cpp	(revision 806)
@@ -115,5 +115,5 @@
     pj_ioqueue_key_t		*key_;
     CPjSocket			*sock_;
-    const pj_ioqueue_callback	*cb_;
+    pj_ioqueue_callback		 cb_;
     void			*user_data_;
 
@@ -156,7 +156,8 @@
 		     const pj_ioqueue_callback *cb, void *user_data)
     : CActive(CActive::EPriorityStandard),
-	  ioqueue_(ioqueue), key_(key), sock_((CPjSocket*)sock), cb_(cb), 
+	  ioqueue_(ioqueue), key_(key), sock_((CPjSocket*)sock), 
 	  user_data_(user_data), aBufferPtr_(NULL, 0), type_(TYPE_NONE)
     {
+    	pj_memcpy(&cb_, cb, sizeof(*cb));
     }
 
@@ -166,4 +167,7 @@
 	CActiveScheduler::Add(this);
     }
+    
+    void HandleReadCompletion();
+    CPjSocket *HandleAcceptCompletion();
 };
 
@@ -217,5 +221,16 @@
 	return PJ_EPENDING;
     } else {
-	return PJ_RETURN_OS_ERROR(iStatus.Int());
+    	// Complete immediately (with success or error)
+    	if (iStatus == KErrNone) {
+    	    *size = aBufferPtr_.Length();
+    	    HandleReadCompletion();
+    	    return PJ_SUCCESS;
+    	}
+    	else {
+	    pending_data_.read_.op_key_ = NULL;
+	    pending_data_.read_.addr_ = NULL;
+	    pending_data_.read_.addrlen_ = NULL;
+	    return PJ_RETURN_OS_ERROR(iStatus.Int());
+    	}
     }
 }
@@ -250,6 +265,78 @@
 	return PJ_EPENDING;
     } else {
-	return PJ_RETURN_OS_ERROR(iStatus.Int());
-    }
+    	// Accept() completed immediately (with success or error).
+    	if (iStatus == KErrNone) {
+    	    HandleAcceptCompletion();
+    	    return PJ_SUCCESS;
+    	}
+    	else {
+	    pending_data_.accept_.op_key_ = NULL;
+	    pending_data_.accept_.new_sock_ = NULL;
+	    pending_data_.accept_.local_ = NULL;
+	    pending_data_.accept_.remote_ = NULL;
+	    pending_data_.accept_.addrlen_ = NULL;
+	    return PJ_RETURN_OS_ERROR(iStatus.Int());
+    	}
+    }
+}
+
+
+//
+// Handle asynchronous RecvFrom() completion
+//
+void CIoqueueCallback::HandleReadCompletion() 
+{
+	if (pending_data_.read_.addr_) {
+	    PjSymbianOS::Addr2pj(aAddress_, 
+				 *(pj_sockaddr_in*)pending_data_.read_.addr_);
+	    pending_data_.read_.addr_ = NULL;
+	}
+	if (pending_data_.read_.addrlen_) {
+	    *pending_data_.read_.addrlen_ = sizeof(pj_sockaddr_in);
+	    pending_data_.read_.addrlen_ = NULL;
+	}
+	
+	pending_data_.read_.op_key_ = NULL;
+}
+
+
+//
+// Handle asynchronous Accept() completion.
+//
+CPjSocket *CIoqueueCallback::HandleAcceptCompletion() 
+{
+	CPjSocket *pjNewSock = new CPjSocket(blank_sock_);
+
+	if (pending_data_.accept_.new_sock_) {
+	    *pending_data_.accept_.new_sock_ = (pj_sock_t)pjNewSock;
+	    pending_data_.accept_.new_sock_ = NULL;
+	}
+
+	if (pending_data_.accept_.local_) {
+	    TInetAddr aAddr;
+	    pj_sockaddr_in *ptr_sockaddr;
+
+	    blank_sock_.LocalName(aAddr);
+	    ptr_sockaddr = (pj_sockaddr_in*)pending_data_.accept_.local_;
+	    PjSymbianOS::Addr2pj(aAddr, *ptr_sockaddr);
+	    pending_data_.accept_.local_ = NULL;
+	}
+
+	if (pending_data_.accept_.remote_) {
+	    TInetAddr aAddr;
+	    pj_sockaddr_in *ptr_sockaddr;
+
+	    blank_sock_.RemoteName(aAddr);
+	    ptr_sockaddr = (pj_sockaddr_in*)pending_data_.accept_.remote_;
+	    PjSymbianOS::Addr2pj(aAddr, *ptr_sockaddr);
+	    pending_data_.accept_.remote_ = NULL;
+	}
+
+	if (pending_data_.accept_.addrlen_) {
+	    *pending_data_.accept_.addrlen_ = sizeof(pj_sockaddr_in);
+	    pending_data_.accept_.addrlen_ = NULL;
+	}
+	
+	return pjNewSock;
 }
 
@@ -275,21 +362,17 @@
 	// Handle failure condition
 	if (iStatus != KErrNone) {
-	    cb_->on_read_complete(key_, op_key, 
-				  -PJ_RETURN_OS_ERROR(iStatus.Int()));
+	    if (cb_.on_read_complete) {
+	    	cb_.on_read_complete( key_, op_key, 
+				      -PJ_RETURN_OS_ERROR(iStatus.Int()));
+	    }
 	    return;
 	}
 
-	if (pending_data_.read_.addr_) {
-	    PjSymbianOS::Addr2pj(aAddress_, 
-				 *(pj_sockaddr_in*)pending_data_.read_.addr_);
-	    pending_data_.read_.addr_ = NULL;
-	}
-	if (pending_data_.read_.addrlen_) {
-	    *pending_data_.read_.addrlen_ = sizeof(pj_sockaddr_in);
-	    pending_data_.read_.addrlen_ = NULL;
-	}
+	HandleReadCompletion();
 
 	/* Call callback */
-	cb_->on_read_complete(key_, op_key, aBufferPtr_.Length());
+	if (cb_.on_read_complete) {
+	    cb_.on_read_complete(key_, op_key, aBufferPtr_.Length());
+	}
 
     } else if (cur_type == TYPE_ACCEPT) {
@@ -306,45 +389,19 @@
 	    if (pending_data_.accept_.new_sock_)
 		*pending_data_.accept_.new_sock_ = PJ_INVALID_SOCKET;
-
-	    cb_->on_accept_complete(key_, op_key, PJ_INVALID_SOCKET,
-				    -PJ_RETURN_OS_ERROR(iStatus.Int()));
+	    
+	    if (cb_.on_accept_complete) {
+	    	cb_.on_accept_complete( key_, op_key, PJ_INVALID_SOCKET,
+				        -PJ_RETURN_OS_ERROR(iStatus.Int()));
+	    }
 	    return;
 	}
 
-	CPjSocket *pjNewSock = new CPjSocket(blank_sock_);
-
-	if (pending_data_.accept_.new_sock_) {
-	    *pending_data_.accept_.new_sock_ = (pj_sock_t)pjNewSock;
-	    pending_data_.accept_.new_sock_ = NULL;
-	}
-
-	if (pending_data_.accept_.local_) {
-	    TInetAddr aAddr;
-	    pj_sockaddr_in *ptr_sockaddr;
-
-	    blank_sock_.LocalName(aAddr);
-	    ptr_sockaddr = (pj_sockaddr_in*)pending_data_.accept_.local_;
-	    PjSymbianOS::Addr2pj(aAddr, *ptr_sockaddr);
-	    pending_data_.accept_.local_ = NULL;
-	}
-
-	if (pending_data_.accept_.remote_) {
-	    TInetAddr aAddr;
-	    pj_sockaddr_in *ptr_sockaddr;
-
-	    blank_sock_.RemoteName(aAddr);
-	    ptr_sockaddr = (pj_sockaddr_in*)pending_data_.accept_.remote_;
-	    PjSymbianOS::Addr2pj(aAddr, *ptr_sockaddr);
-	    pending_data_.accept_.remote_ = NULL;
-	}
-
-	if (pending_data_.accept_.addrlen_) {
-	    *pending_data_.accept_.addrlen_ = sizeof(pj_sockaddr_in);
-	    pending_data_.accept_.addrlen_ = NULL;
-	}
-
+	CPjSocket *pjNewSock = HandleAcceptCompletion();
+	
 	// Call callback.
-	cb_->on_accept_complete(key_, op_key, (pj_sock_t)pjNewSock, 
-				PJ_SUCCESS);
+	if (cb_.on_accept_complete) {
+	    cb_.on_accept_complete( key_, op_key, (pj_sock_t)pjNewSock, 
+				    PJ_SUCCESS);
+	}
     }
 
@@ -375,7 +432,8 @@
     Cancel();
 
-    if (cur_type == TYPE_READ)
-	cb_->on_read_complete(key_, op_key, bytes_status);
-    else if (cur_type == TYPE_ACCEPT)
+    if (cur_type == TYPE_READ) {
+    	if (cb_.on_read_complete)
+    	    cb_.on_read_complete(key_, op_key, bytes_status);
+    } else if (cur_type == TYPE_ACCEPT)
 	;
 }
Index: /pjproject/branches/symbian/pjlib/src/pjlib-test/main_symbian.cpp
===================================================================
--- /pjproject/branches/symbian/pjlib/src/pjlib-test/main_symbian.cpp	(revision 805)
+++ /pjproject/branches/symbian/pjlib/src/pjlib-test/main_symbian.cpp	(revision 806)
@@ -71,5 +71,5 @@
 void MyScheduler::Error(TInt aError) const
 {
-    int i = 0;
+    PJ_UNUSED_ARG(aError);
 }
 
@@ -155,4 +155,6 @@
     wchar_t buf16[PJ_LOG_MAX_SIZE];
 
+    PJ_UNUSED_ARG(level);
+    
     pj_ansi_to_unicode(buf, len, buf16, PJ_ARRAY_SIZE(buf16));
 
Index: /pjproject/branches/symbian/pjlib/src/pjlib-test/sock.c
===================================================================
--- /pjproject/branches/symbian/pjlib/src/pjlib-test/sock.c	(revision 805)
+++ /pjproject/branches/symbian/pjlib/src/pjlib-test/sock.c	(revision 806)
@@ -67,5 +67,5 @@
 #define UDP_PORT	51234
 #define TCP_PORT        (UDP_PORT+10)
-#define BIG_DATA_LEN	9000
+#define BIG_DATA_LEN	8192
 #define ADDRESS		"127.0.0.1"
 
@@ -350,5 +350,5 @@
 	rc = -121; goto on_error;
     }
-	    
+
     /* Test send/recv, with sendto */
     rc = send_recv_test(PJ_SOCK_DGRAM, ss, cs, &dstaddr, NULL, 
@@ -362,5 +362,7 @@
     if (rc != 0)
 	goto on_error;
-
+    
+// This test will fail on S60 3rd Edition MR2
+#if 1
     /* connect() the sockets. */
     rc = pj_sock_connect(cs, &dstaddr, sizeof(dstaddr));
@@ -380,4 +382,5 @@
     if (rc != 0)
 	goto on_error;
+#endif
 
 on_error:
@@ -437,4 +440,55 @@
 }
 
+#if 0
+#include "../pj/os_symbian.h"
+static int connect_test()
+{
+	RSocketServ rSockServ;
+	RSocket rSock;
+	TInetAddr inetAddr;
+	TRequestStatus reqStatus;
+	char buffer[16];
+	TPtrC8 data((const TUint8*)buffer, (TInt)sizeof(buffer));
+ 	int rc;
+	
+	rc = rSockServ.Connect();
+	if (rc != KErrNone)
+		return rc;
+	
+	rc = rSock.Open(rSockServ, KAfInet, KSockDatagram, KProtocolInetUdp);
+    	if (rc != KErrNone) 
+    	{    		
+    		rSockServ.Close();
+    		return rc;
+    	}
+   	
+    	inetAddr.Init(KAfInet);
+    	inetAddr.Input(_L("127.0.0.1"));
+    	inetAddr.SetPort(80);
+    	
+    	rSock.Connect(inetAddr, reqStatus);
+    	User::WaitForRequest(reqStatus);
+
+    	if (reqStatus != KErrNone) {
+		rSock.Close();
+    		rSockServ.Close();
+		return rc;
+    	}
+    
+    	rSock.Send(data, 0, reqStatus);
+    	User::WaitForRequest(reqStatus);
+    	
+    	if (reqStatus!=KErrNone) {
+    		rSock.Close();
+    		rSockServ.Close();
+    		return rc;
+    	}
+    	
+    	rSock.Close();
+    	rSockServ.Close();
+	return KErrNone;
+}
+#endif
+
 int sock_test()
 {
@@ -443,4 +497,11 @@
     pj_create_random_string(bigdata, BIG_DATA_LEN);
 
+// Enable this to demonstrate the error witn S60 3rd Edition MR2
+#if 0
+    rc = connect_test();
+    if (rc != 0)
+    	return rc;
+#endif
+    
     rc = format_test();
     if (rc != 0)
Index: /pjproject/branches/symbian/pjsip-apps/src/samples/main_symbian.cpp
===================================================================
--- /pjproject/branches/symbian/pjsip-apps/src/samples/main_symbian.cpp	(revision 805)
+++ /pjproject/branches/symbian/pjsip-apps/src/samples/main_symbian.cpp	(revision 806)
@@ -34,4 +34,8 @@
     //
     char *argv[] = { "main_symbian", NULL };
+    
+    //console->Printf(_L("Press any key to start\n"));
+    //console->Getch();
+    
     int rc = pj_app_main(1, argv);
 
Index: /pjproject/branches/symbian/pjsip-apps/src/samples/sipstateless.c
===================================================================
--- /pjproject/branches/symbian/pjsip-apps/src/samples/sipstateless.c	(revision 805)
+++ /pjproject/branches/symbian/pjsip-apps/src/samples/sipstateless.c	(revision 806)
@@ -142,4 +142,5 @@
     {
 	pj_sockaddr_in addr;
+	pjsip_host_port a_name;
 
 	addr.sin_family = PJ_AF_INET;
@@ -147,5 +148,8 @@
 	addr.sin_port = pj_htons(5060);
 
-	status = pjsip_udp_transport_start( sip_endpt, &addr, NULL, 1, NULL);
+	a_name.host = pj_str("127.0.0.1");
+	a_name.port = 5060;
+	
+	status = pjsip_udp_transport_start( sip_endpt, &addr, &a_name, 1, NULL);
 	if (status != PJ_SUCCESS) {
 	    char errmsg[PJ_ERR_MSG_SIZE];
