devxlogo

Tip Bank

Calling a SOCKS Proxy Server from Java

This tip shows you how to call a SOCKS proxy server from Java code using the Socket class: SocketAddress addr=new InetSocketAddress(?socks_server_proxy?, socks_port);Proxy proxy=new Proxy(Proxy.Type.SOCKS,addr);Socket socket=new Socket(proxy);InetSocketAddress final_addr=new InetSocketAddress(?final_server?, final_port);socket.connect(final_addr);?

Controlling Checkboxes in MFC

Here’s how to check, uncheck, enable, and disable a checkbox in MFC: CButton* pBtn = (CButton*) GetDlgItem(IDC_SETUP_AM); pBtn-&gtSetCheck(0);// uncheck it CButton* pBtn = (CButton*) GetDlgItem(IDC_SETUP_AM); pBtn->SetCheck(1);// check it CButton* pBtn

Upload Large Files

By default, ASP.NET doesn’t allow you to upload files bigger than 4MB to the server. You can fix this by overriding the default value of 4MB in the web.config file.

Authenticate to a Proxy Server

To provide a user’s password to a proxy server, use the following code: URLConnection URLcon=null;URLcon = url.openConnection();byte[] x=”name:password”.getBytes();//coding in Base64String s = new sun.misc.BASE64Encoder().encode(x); URLcon.setRequestProperty( “Proxy-Authorization”,s);

Problem with Parsing Date in Different Regions

Regional settings, especially dates, are always a problem in code. For example, suppose the product is developed in U.S. and deployed in UK. Users entering dates in UK format would

Work with SSL/LDAP Using Java

Most applications nowadays authenticate through LDAP (directory service). To set this up, first register the SSL certificate using the keytool utility, as shown below: Register ssl certificate using keytool:keytool -import

Create XML from an Array

Passing arrays as arguments to stored procedures is not currently possible in SQL Server, but you can use XML to accomplish this. To do this, you need to create an