Upload a file to IIS using WEBDAV

Sharmistha Chatterjee sharmi.chatterjee at gmail.com
Fri Nov 16 03:24:23 EST 2012


I am trying to upload a file to IIS server with the following code and I am 
getting the error

"Could not connect to server, connefction refused"

If I change HTTPS to HTTP and the port number to 80 and comment this line 
ne_ssl_trust_default_ca(dav); then it gives 

"Could not connect to the server, ignored Negotiate challenge , ignored NTLM 

Can anybody please help

// Useful C libraries
#include <stdio.h>
#include <fcntl.h>

// Inclusion of the neon library
#include <ne_session.h>
#include <ne_socket.h>
#include <ne_auth.h>
 #include <ne_basic.h>
#include <ne_ssl.h>
#include <ne_uri.h>

// URL allowing the iKeepinCloud connection and authentication information for 
the connection
char * url = "172.20.x.x";
 char * user = "sharmi";
char * pass = "mypass";

static int define_auth(void *userdata, const char *realm, int attempts, char 
*username, char *password) {
strncpy(username, user, NE_ABUFSIZ);
 strncpy(password, pass, NE_ABUFSIZ);
return attempts;

int main(void)
ne_session * dav;
int res, fd;

// Global initialization (socket - SSL)

// Create a new dav client via neon in https (port:443)
 dav = ne_session_create("https", url, 443);

// Define authentication information for the URL via callback
// (necessary when the client requests access to a protected resource
ne_set_server_auth(dav, define_auth, NULL);
// Indicates that the iKeepinCloud certificate is accepted

// Read file for upload
fd = open("/testdav/test_file.txt", O_RDONLY);

// Upload to test file/test.txt
res = ne_put(dav, "/test/test.txt", fd);
if(res!=NE_OK){ printf("Request failed: %s\n", ne_get_error(dav)); }


More information about the neon mailing list